/** * Changes the currently enabled modules. Module paths may be relative * or absolute, but must point to a directory: * * self::modules(array('modules/foo', MODPATH.'bar')); * * @param array list of module paths * @return array enabled modules */ public static function modules(array $modules = NULL) { if ($modules === NULL) { return self::$_modules; } // Start a new list of include paths, APPPATH first $paths = array(APP_PATH); foreach ($modules as $name => &$path) { $path = MOD_PATH . $path; if (is_dir($path)) { // Add the module to include paths $paths[] = $modules[$name] = $path; } else { // This module is invalid, remove it unset($modules[$name]); } } // Finish the include paths by adding SYS_PATH $paths[] = SYS_PATH; // Set the new include paths self::$_paths = $paths; // Set the current module list self::$_modules = $modules; foreach (self::$_modules as $path) { $init = $path . DIRECTORY_SEPARATOR . 'init.php'; if (is_file($init)) { require_once $init; } } return self::$_modules; }