/** * Changes the currently enabled modules. Module paths may be relative * or absolute, but must point to a directory: * * Kohana::modules(array('modules/foo', MODPATH.'bar')); * * @param array $modules list of module paths * @return array enabled modules * @throws \InvalidArgumentException */ public static function modules(array $modules = NULL) { if ($modules === NULL) { // Not changing modules, just return the current set return Kohana::$_modules; } // Start a new list of include paths, APPPATH first $paths = array(APPPATH); foreach ($modules as $name => $path) { if (is_dir($path)) { // Add the module to include paths $paths[] = $modules[$name] = realpath($path) . DS; } else { // This module is invalid, remove it throw new \InvalidArgumentException(sprintf('Attempted to load an invalid or missing module %s at %s', $name, realpath($path))); } } // Include GLZPATH before system for CFS $paths[] = GLZPATH; // Finish the include paths by adding SYSPATH $paths[] = SYSPATH; // Set the new include paths Kohana::$_paths = $paths; // Set the current module list Kohana::$_modules = $modules; /** Run Gleez Components */ Gleez::ready(); foreach (Kohana::$_modules as $path) { $init = $path . 'init' . EXT; if (is_file($init)) { // Include the module initialization file once require_once $init; } } if (is_file(GLZPATH . 'init' . EXT)) { //@todo better handling instead of init require_once GLZPATH . 'init' . EXT; } return Kohana::$_modules; }