diff --git a/sources/Application/TwigBase/Controller/Controller.php b/sources/Application/TwigBase/Controller/Controller.php index 1a08df324..d09d47c17 100644 --- a/sources/Application/TwigBase/Controller/Controller.php +++ b/sources/Application/TwigBase/Controller/Controller.php @@ -56,11 +56,14 @@ use ZipArchive; abstract class Controller extends AbstractController { - const ENUM_PAGE_TYPE_HTML = 'html'; - const ENUM_PAGE_TYPE_BASIC_HTML = 'basic_html'; - const ENUM_PAGE_TYPE_AJAX = 'ajax'; + const ENUM_PAGE_TYPE_HTML = 'html'; + const ENUM_PAGE_TYPE_BASIC_HTML = 'basic_html'; + const ENUM_PAGE_TYPE_AJAX = 'ajax'; const ENUM_PAGE_TYPE_TURBO_FORM_AJAX = 'turbo_ajax'; - const ENUM_PAGE_TYPE_SETUP = 'setup'; + const ENUM_PAGE_TYPE_SETUP = 'setup'; + + const TWIG_ERROR = 'error'; + const TWIG_WARNING = 'warning'; /** @var \Twig\Environment */ private $oTwig; @@ -105,12 +108,15 @@ abstract class Controller extends AbstractController /** @var CsrfTokenManager Csrf manager (from Symfony form component @link https://symfony.com/doc/current/security/csrf.html) */ private CsrfTokenManager $oCsrfTokenManager; private ?string $sContentType = null; + private ?string $sPageType = null; /** * Controller constructor. * * @param string $sViewPath Path of the twig files * @param string $sModuleName name of the module (or 'core' if not a module) + * + * @throws \ReflectionException */ public function __construct($sViewPath = '', $sModuleName = 'core', $aAdditionalPaths = []) { @@ -190,12 +196,10 @@ abstract class Controller extends AbstractController $sModulePath = dirname(dirname($this->GetDir())); $this->SetModuleName(basename($sModulePath)); $this->SetViewPath($sModulePath.'/view'); - try - { + try { $this->aDefaultParams = array('sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php')); } - catch (Exception $e) - { + catch (Exception $e) { IssueLog::Error($e->getMessage()); } } @@ -245,8 +249,7 @@ abstract class Controller extends AbstractController */ public function HandleOperation() { - try - { + try { $this->CheckAccess(); $this->m_sOperation = utils::ReadParam('operation', $this->sDefaultOperation); @@ -261,8 +264,7 @@ abstract class Controller extends AbstractController $this->DisplayBadRequest(); } - catch (Exception $e) - { + catch (Exception $e) { http_response_code(500); $oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError')); $oP->add("