Contao\FrontendIndex::run PHP Метод

run() публичный Метод

Run the controller
public run ( ) : Response
Результат Symfony\Component\HttpFoundation\Response
    public function run()
    {
        $pageId = $this->getPageIdFromUrl();
        $objRootPage = null;
        // Load a website root page object if there is no page ID
        if ($pageId === null) {
            $objRootPage = $this->getRootPageFromUrl();
            /** @var PageRoot $objHandler */
            $objHandler = new $GLOBALS['TL_PTY']['root']();
            $pageId = $objHandler->generate($objRootPage->id, true, true);
        } elseif ($pageId === false) {
            $this->User->authenticate();
            throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
        }
        $pageModel = \PageModel::findPublishedByIdOrAlias($pageId);
        // Throw a 404 error if the page could not be found
        if ($pageModel === null) {
            throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
        }
        return $this->renderPage($pageModel);
    }

Usage Example

Пример #1
0
 /**
  * Runs the main front end controller.
  *
  * @return Response
  */
 public function indexAction()
 {
     $this->container->get('contao.framework')->initialize();
     $controller = new FrontendIndex();
     return $controller->run();
 }