src/Controller/DefaultController.php line 26

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of the Pimcore X Installation by
  4.  * ercas GmbH & CO. KG <https://www.ercasdieagentur.de>
  5.  *
  6.  *  @license GPLv3
  7.  */
  8. namespace App\Controller;
  9. use Pimcore\Controller\FrontendController;
  10. use Pimcore\Model\Document;
  11. use Pimcore\Tool;
  12. use Symfony\Component\HttpFoundation\RedirectResponse;
  13. use Symfony\Component\HttpFoundation\Request;
  14. class DefaultController extends FrontendController
  15. {
  16.     public function damageAction(Request $request)
  17.     {
  18.         return $this->render('layout/damage-declaration.html.twig', []);
  19.     }
  20.     public function defaultAction(Request $request)
  21.     {
  22.         $access$this->checkPagePermissions();
  23.         if (!$access) {
  24.             $accessDeniedDocument $this->getAccessDeniedDocument();
  25.             //$baseUrl = Tool::getHostUrl();
  26.             $baseUrl '';
  27.             return new RedirectResponse($baseUrl.$accessDeniedDocument->getFullPath());
  28.         }
  29.         return $this->render('html/02_body/02_main/main.html.twig', []);
  30.     }
  31.     public function angularAction(Request $request)
  32.     {
  33.         $access$this->checkPagePermissions();
  34.         if (!$access) {
  35.             $accessDeniedDocument $this->getAccessDeniedDocument();
  36.              //$baseUrl = Tool::getHostUrl();
  37.              $baseUrl '';
  38.             return new RedirectResponse($baseUrl.$accessDeniedDocument->getFullPath());
  39.         }
  40.         return $this->render('html/02_body/angular.html.twig', []);
  41.     }
  42.     public function mailAction(Request $request)
  43.     {
  44.         return $this->render('mail/mail.html.twig', []);
  45.     }
  46.     public function mailActionCustom(Request $request)
  47.     {
  48.         return $this->render('mail/custom-mail.html.twig', ['params'=>null]);
  49.     }
  50.     private function checkPagePermissions()
  51.     {
  52.         $permission$this->document->getProperty('pagePermissions');
  53.         if ($permission && !$this->editmode) {
  54.             return  $this->isGranted($permission);
  55.         }
  56.         return true;
  57.     }
  58.     private function getAccessDeniedDocument()
  59.     {
  60.         if ($this->document->hasProperty('accessDeniedPage')) {
  61.             $accessDeniedDocId=$this->document->getProperty('accessDeniedPage')->getId();
  62.         } else {
  63.             $accessDeniedDocId=1;
  64.         }
  65.         return  Document::getById($accessDeniedDocId);
  66.     }
  67. }