<?php
/**
* This file is part of the Pimcore X Installation by
* ercas GmbH & CO. KG <https://www.ercasdieagentur.de>
*
* @license GPLv3
*/
namespace App\Controller;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\Document;
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends FrontendController
{
public function damageAction(Request $request)
{
return $this->render('layout/damage-declaration.html.twig', []);
}
public function defaultAction(Request $request)
{
$access= $this->checkPagePermissions();
if (!$access) {
$accessDeniedDocument = $this->getAccessDeniedDocument();
//$baseUrl = Tool::getHostUrl();
$baseUrl = '';
return new RedirectResponse($baseUrl.$accessDeniedDocument->getFullPath());
}
return $this->render('html/02_body/02_main/main.html.twig', []);
}
public function angularAction(Request $request)
{
$access= $this->checkPagePermissions();
if (!$access) {
$accessDeniedDocument = $this->getAccessDeniedDocument();
//$baseUrl = Tool::getHostUrl();
$baseUrl = '';
return new RedirectResponse($baseUrl.$accessDeniedDocument->getFullPath());
}
return $this->render('html/02_body/angular.html.twig', []);
}
public function mailAction(Request $request)
{
return $this->render('mail/mail.html.twig', []);
}
public function mailActionCustom(Request $request)
{
return $this->render('mail/custom-mail.html.twig', ['params'=>null]);
}
private function checkPagePermissions()
{
$permission= $this->document->getProperty('pagePermissions');
if ($permission && !$this->editmode) {
return $this->isGranted($permission);
}
return true;
}
private function getAccessDeniedDocument()
{
if ($this->document->hasProperty('accessDeniedPage')) {
$accessDeniedDocId=$this->document->getProperty('accessDeniedPage')->getId();
} else {
$accessDeniedDocId=1;
}
return Document::getById($accessDeniedDocId);
}
}