Welcome Guest, Not a member yet? Register   Sign In
CI 3 & HMVC Issue
#7

(This post was last modified: 04-17-2015, 02:04 PM by mwhitney. Edit Reason: remove smiley )

If you look in the MX/Loader and find the module() method (which is called when you use $this->load->module(); ) you'll see something like this:


PHP Code:
    /** Load a module controller **/
    
public function module($module$params NULL)    
    {
        if (
is_array($module)) return $this->modules($module);

        
$_alias strtolower(basename($module));
        
CI::$APP->$_alias Modules::load(array($module => $params));
        return 
$this;
    } 

To explain this code a little, assume that CI::$APP is going to be $this in your calling method, and as we see in the line above it, $_alias is the lowercase name of your module. So the loader loads the controller for your module and places the controller instance into CI::$APP->$_alias, so you can access the controller instance from $this->lowercase_name_of_your_module.

If you always pass lowercased strings to the loader, this behavior is actually very consistent with a standard CI installation. Almost anything you load becomes available on $this->lowercase_name_of_loaded_class, with the most common exception being helpers, which don't normally contain classes anyway.
Reply


Messages In This Thread
CI 3 & HMVC Issue - by rfulcher - 04-13-2015, 04:59 PM
RE: CI 3 & HMVC Issue - by rfulcher - 04-13-2015, 06:25 PM
RE: CI 3 & HMVC Issue - by rfulcher - 04-13-2015, 06:29 PM
RE: CI 3 & HMVC Issue - by rfulcher - 04-13-2015, 06:45 PM
RE: CI 3 & HMVC Issue - by rfulcher - 04-14-2015, 08:49 AM
RE: CI 3 & HMVC Issue - by rfulcher - 04-16-2015, 05:50 AM
RE: CI 3 & HMVC Issue - by mwhitney - 04-17-2015, 02:03 PM
RE: CI 3 & HMVC Issue - by CroNiX - 04-18-2015, 03:16 PM
RE: CI 3 & HMVC Issue - by celiomap - 08-15-2016, 05:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB