Example #1
0
 /**
  * @param string|array $route
  * @param array $headers
  * @param array $request_params
  */
 static function load($route = '', $headers = array(), array $request_params = array())
 {
     $controller_route = new self($route, $headers, $request_params);
     $controller = $controller_route->getController();
     if (null === $controller) {
         file_not_found($route);
     }
     $controller->doAction($controller_route->getAction(), $controller_route->getParams());
 }
Example #2
0
 /**
  * Creates a Dispatcher instance from MVC parameters.
  *
  * @param string $module     Module name.
  * @param string $controller Controller name.
  * @param string $action     Action name.
  * @param array  $params     Parameters.
  *
  * @return Dispatcher
  */
 public static function mvcDispatcher($module, $controller, $action, $params)
 {
     $dispatcher = new self();
     $dispatcher->setModule($module);
     $dispatcher->setController($controller);
     $dispatcher->setAction($action);
     $dispatcher->setParams($params);
     // get current application config
     $applicationConfig = Bootstrap::getInstance()->getEnvironment()->getApplicationConfig();
     // build the class name
     $className = '\\' . $applicationConfig->Namespace . '\\Modules\\' . $dispatcher->getModule() . '\\Controllers\\' . $dispatcher->getController();
     $dispatcher->setClassName($className);
     return $dispatcher;
 }