Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function controller(Controller $controller, $code = Response::HTTP_OK, $headers = array())
 {
     $request = $this->request;
     if ($response = $controller->on_start()) {
         return $response;
     }
     if ($controller instanceof PageController) {
         if ($controller->isReplaced()) {
             return $this->controller($controller->getReplacement(), $code, $headers);
         }
         $controller->setupRequestActionAndParameters($request);
         $response = $controller->validateRequest();
         // If validaterequest returned a response
         if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
             return $response;
         } else {
             // If validateRequest did not return true
             if ($response == false) {
                 return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
             }
         }
         $requestTask = $controller->getRequestAction();
         $requestParameters = $controller->getRequestActionParameters();
         $response = $controller->runAction($requestTask, $requestParameters);
         if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
             return $response;
         }
     } else {
         if ($response = $controller->runAction('view')) {
             return $response;
         }
     }
     $view = $controller->getViewObject();
     // Mobile theme
     if ($this->config->get('concrete.misc.mobile_theme_id') > 0) {
         $md = $this->app->make(MobileDetect::class);
         if ($md->isMobile()) {
             $mobileTheme = Theme::getByID(Config::get('concrete.misc.mobile_theme_id'));
             if ($mobileTheme instanceof Theme) {
                 $view->setViewTheme($mobileTheme);
                 $controller->setTheme($mobileTheme);
             }
         }
     }
     return $this->view($view, $code, $headers);
 }