[eluser]riwakawd[/eluser]
I am now using
https://github.com/jenssegers/CodeIgniter-HMVC-Modules
I would like to know how to make Module sub-directory and Default controller to be able to be located in extra folder.
Example: modules/admin/controllers/common/controller.php I know for the original hmvc you can but the one I use is a slimmed down version. And has couple things changed on it.
Default Controller is at bottom of code i need that to also be able to work like so.
modules/admin/controllers/common/controller.php
Any ideas.
https://github.com/jenssegers/CodeIgnite...Router.php
Code:
function locate($segments) {
list($module, $directory, $controller) = array_pad($segments, 3, NULL);
foreach ($this->config->item('modules_locations') as $location) {
$relative = $location;
// Make path relative to controllers directory
$start = rtrim(realpath(FCPATH . APPPATH), '/');
$parts = explode('/', str_replace('\\', '/', $start));
// Iterate all parts and replace absolute part with relative part
for ($i = 1; $i <= count($parts); $i++) {
$relative = str_replace(implode('/', $parts) . '/', str_repeat('../', $i), $relative, $count);
array_pop($parts);
// Stop iteration if found
if ($count)
break;
}
// Does a module exist? (/modules/xyz/controllers/)
if (is_dir($source = $location . $module . '/controllers/')) {
$this->module = $module;
$this->directory = $relative . $module . '/controllers/';
// Module root controller?
if ($directory && is_file($source . $directory . '.php')) {
$this->class = $directory;
return array_slice($segments, 1);
}
// Module sub-directory?
if ($directory && is_dir($source . $directory . '/')) {
$source = $source . $directory . '/';
$this->directory .= $directory . '/';
// Module sub-directory controller?
if (is_file($source . $directory . '.php')) {
return array_slice($segments, 1);
}
// Module sub-directory default controller?
if (is_file($source . $this->default_controller . '.php')) {
$segments[1] = $this->default_controller;
return array_slice($segments, 1);
}
// Module sub-directory sub-controller?
if ($controller && is_file($source . $controller . '.php')) {
return array_slice($segments, 2);
}
}
// Module controller?
if (is_file($source . $module . '.php')) {
return $segments;
}
// Module default controller?
if (is_file($source . $this->default_controller . '.php')) {
$segments[0] = $this->default_controller;
return $segments;
}
}
}
// Root folder controller?
if (is_file(APPPATH . 'controllers/' . $module . '.php')) {
return $segments;
}
// Sub-directory controller?
if ($directory && is_file(APPPATH . 'controllers/' . $module . '/' . $directory . '.php')) {
$this->directory = $module . '/';
return array_slice($segments, 1);
}
// Default controller?
if (is_file(APPPATH . 'controllers/' . $module . '/' . $this->default_controller . '.php')) {
$segments[0] = $this->default_controller;
return $segments;
}
}