-
Notifications
You must be signed in to change notification settings - Fork 0
HMVC for DMZ Modular Separation
With this modification on DMZ class you will be able to use Modular Separation with DMZ
Topic for discusion: http://codeigniter.com/forums/viewthread/154339/
Tested on: [Modular Extensions - HMVC] 5.2.31 (http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/) [DMZ] 1.7.1 (http://www.overzealous.com/dmz/pages/download.html)
[b]HMVC for DMZ Modular Separation 0.1[/b]
By now I only change the way DMZ load the classes with native php 5 autoloader
-
Replace this: [code] public static function autoload($class) { // Don't attempt to autoload CI_ or MY_ prefixed classes if (in_array(substr($class, 0, 3), array('CI_', 'EE_', 'MY_'))) { return; }
// Prepare class $class = strtolower($class); $CI =& get_instance(); // Prepare path if (isset($CI->load->_ci_model_paths) && is_array($CI->load->_ci_model_paths)) { // use CI loader's model path $paths = $CI->load->_ci_model_paths; } else { $paths = array(APPPATH); } foreach ($paths as $path) { // Prepare file $file = $path . 'models/' . $class . EXT; // Check if file exists, require_once if it does if (file_exists($file)) { require_once($file); break; } } // if class not loaded, do a recursive search of model paths for the class if (! class_exists($class)) { foreach($paths as $path) { $found = DataMapper::recursive_require_once($class, $path . 'models'); if($found) { break; } } }
} [/code]
-
For this: [code] public static function autoload($class) { // Don't attempt to autoload CI_ or MY_ prefixed classes if (in_array(substr($class, 0, 3), array('CI_', 'EE_', 'MY_'))) { return; }
// Prepare class $class = strtolower($class); $CI =& get_instance(); // Prepare path if (isset($CI->load->_ci_model_paths) && is_array($CI->load->_ci_model_paths)) { // use CI loader's model path $paths = $CI->load->_ci_model_paths; } else { $paths = array(APPPATH); } foreach ($paths as $path) { // Prepare file $file = $path . 'models/' . $class . EXT; // Check if file exists, require_once if it does if (file_exists($file)) { require_once($file); break; }else{ $array = debug_backtrace(); $modules = $array[1]['file']; $modules = substr($modules, (strpos($modules, 'modules')+8)); $separador = ''; if(strpos($modules, '\\') ){// Windows $separador = strpos($modules, '\\'); }elseif(strpos($modules, '/') ){// Linux $separador = strpos($modules, '/'); } $module = strtolower(substr($modules, 0, $separador)); $file_module = $path . 'modules/' . $module . '/models/' . $class . EXT; if (file_exists($file_module)) { require_once($file_module); break; } } } // if class not loaded, do a recursive search of model paths for the class if (! class_exists($class)) { foreach($paths as $path) { $found = DataMapper::recursive_require_once($class, $path . 'models'); if($found) { break; } $found = DataMapper::recursive_require_once($class, $path . 'modules/' . $module . '/models'); if($found) { break; } } }
} [/code]
text: Category:DMZ Extensions