/** * Builds the routes then processes the request to the controller and method. * @param array $config The config array with the controller path and routes. */ public static function init(array $config) { static::$controller_path = $config['controller_path']; foreach ($config['routes'] as $route => $args) { if (!is_array($args)) { $args = array($args, 'params' => array()); } static::$routes[$route] = $args; } static::$request = static::get_request(); static::route(); }
public static function setControllerPath($path) { static::$controller_path = realpath($path); }
/** * Start routing process. * * @return void */ public static function go() { // Define controllers root path. static::$controller_path = ROOT . '/controllers'; // Get segments of url. static::segments(); // Check if exists subpath in controllers path. static::path_exists(); // Instance controller. static::controller(); // Define action for call. static::action(); $controller = static::$controller; $action = static::$action; $controller->$action(); }