Exemple #1
0
 /**
  * @param Ajde_Core_Route $route
  *
  * @return Ajde_View
  */
 public static function fromRoute($route)
 {
     if (!$route instanceof Ajde_Core_Route) {
         $route = new Ajde_Core_Route($route);
     }
     $base = MODULE_DIR . $route->getModule() . '/';
     $action = $route->getController() ? $route->getController() . '/' . $route->getAction() : $route->getAction();
     $format = $route->getFormat();
     return new self($base, $action, $format);
 }
Exemple #2
0
 /**
  * @param Ajde_Core_Route $route
  *
  * @return Ajde_Controller
  */
 public static function fromRoute(Ajde_Core_Route $route)
 {
     if ($controller = $route->getController()) {
         $moduleController = ucfirst($route->getModule()) . ucfirst($controller) . 'Controller';
     } else {
         $moduleController = ucfirst($route->getModule()) . 'Controller';
     }
     if (!class_exists($moduleController)) {
         // Prevent resursive 404 routing
         $errorRoutes = config('routes.errors');
         if (isset($errorRoutes[Ajde_Http_Response::RESPONSE_TYPE_NOTFOUND])) {
             $notFoundRoute = new Ajde_Core_Route($errorRoutes[Ajde_Http_Response::RESPONSE_TYPE_NOTFOUND]);
             if ($route->buildRoute() == $notFoundRoute->buildRoute()) {
                 Ajde_Http_Response::setResponseType(404);
                 die('<h2>Ouch, something broke.</h2><p>This is serious. We tried to give you a nice error page, but even that failed.</p><button onclick="location.href=\'' . config('app.rootUrl') . '\';">Go back to homepage</button>');
             }
         }
         if (class_exists('Ajde_Exception')) {
             $exception = new Ajde_Core_Exception_Routing("Controller {$moduleController} for module {$route->getModule()} not found", 90008);
         } else {
             // Normal exception here to prevent [Class 'Ajde_Exception' not found] errors...
             $exception = new Exception("Controller {$moduleController} for module {$route->getModule()} not found");
         }
         Ajde::routingError($exception);
     }
     $controller = new $moduleController($route->getAction(), $route->getFormat());
     $controller->_route = $route;
     foreach ($route->values() as $part => $value) {
         $controller->set($part, $value);
     }
     return $controller;
 }
 /**
  *
  * @param Ajde_Core_Route $route
  * @return Ajde_Controller
  */
 public static function fromRoute(Ajde_Core_Route $route)
 {
     if ($controller = $route->getController()) {
         $moduleController = ucfirst($route->getModule()) . ucfirst($controller) . 'Controller';
     } else {
         $moduleController = ucfirst($route->getModule()) . 'Controller';
     }
     if (!Ajde_Core_Autoloader::exists($moduleController)) {
         $exception = new Ajde_Exception("Controller {$moduleController} for module {$route->getModule()} not found", 90008);
         Ajde::routingError($exception);
     }
     $controller = new $moduleController($route->getAction(), $route->getFormat());
     $controller->_route = $route;
     foreach ($route->values() as $part => $value) {
         $controller->set($part, $value);
     }
     return $controller;
 }