Welcome Guest, Not a member yet? Register   Sign In
HMVC loading driver across modules
#3

Its interesting that the default CI driver->load($child) method goes looking in all Package paths, when a child driver by convention lives in sub-directory of the parent. I can see your code resolves that neatly.

I simply altered the shorter __get($child) magic method because there is less code to override - so less chance of clash with future CI changes. I guess HMCV already changes a lot of core code anyhow and this risks that load($child) calls still fail.

Another small change I needed to makeĀ  - from line 196 of third_party/MX/Modules.php - to load drivers/libraries across modules:

PHP Code:
foreach($modules as $module => $subpath
{            
    
$fullpath $location.$module.'/'.$base.$subpath;

    if (
$base == 'libraries/' OR $base == 'models/')
    {
        if(
is_file($fullpath.ucfirst($file_ext))) return array($fullpathucfirst($file));
        
/*
         * EDITS
         * check for drivers loaded across modules in a subdir with same name as file
         * the core library loader does the same trick, but MX one does not
         */
        
else if($base == 'libraries/')
        {
                
$fullpath $fullpath.ucfirst($file).'/'//file here is /classname
                
if(is_file($fullpath.ucfirst($file_ext))) return array($fullpathucfirst($file));
        }
        
/*
         * END EDIT
         */
    
}
    else
    
/* load non-class files */
    
if (is_file($fullpath.$file_ext)) return array($fullpath$file);


This allows me to load a driver with $this->load('module/driver') across modules as shown in the code above.
Reply


Messages In This Thread
HMVC loading driver across modules - by reanvdm - 04-22-2016, 08:19 AM
RE: HMVC loading driver across modules - by reanvdm - 04-23-2016, 11:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB