/** * get an instance of Route class * load all routes * @return instance $route Routes() */ protected function get_routes() { static $routes = null; if (null === $routes) { $routes = new Route(); $routes->load_routes(); } return $routes; }
/** * Add module * * Registers a given module as a class prefix and returns the path to the * module. Won't register twice, will just return the path on a second call. * * @param string module name (lowercase prefix without underscore) * @param bool whether it is an active package */ public static function add_module($name, $active = false) { $paths = \Config::get('module_paths', array()); if (empty($paths)) { return false; } $path = Autoloader::namespace_path('\\'.ucfirst($name)); if ( ! $path) { foreach ($paths as $path) { if (is_dir($mod_check_path = $path.strtolower($name).DS)) { $path = $mod_check_path; $ns = '\\'.ucfirst($name); Autoloader::add_namespaces(array( $ns => $path.'classes'.DS, $ns.'\\Model' => $path.'classes'.DS.'model'.DS, $ns.'\\Controller' => $path.'classes'.DS.'controller'.DS, ), true); Autoloader::add_namespace_aliases(array( $ns.'\\Controller' => 'Fuel\\App', $ns.'\\Model' => 'Fuel\\App', $ns => 'Fuel\\App', ), true); break; } } } // not found if ( ! $path) { return false; } // add the module path static::add_path($path); // get the path for this modules namespace $path = Autoloader::namespace_path('\\'.ucfirst($name)); // Active modules get their path prefixed and routes loaded if ($active) { static::add_path($path, true); // We want active modules to be able to have their own routes, so we reload routes. \Route::load_routes(true); return $path; } static::add_path($path); return $path; }