Example #1
0
 /**
  * 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();
 }
Example #2
0
 public static function setControllerPath($path)
 {
     static::$controller_path = realpath($path);
 }
Example #3
0
        /**
         * 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();
	}