diff --git a/src/Controller/CRUDController.php b/src/Controller/CRUDController.php index b7245b8d91..444b96c96f 100644 --- a/src/Controller/CRUDController.php +++ b/src/Controller/CRUDController.php @@ -997,15 +997,18 @@ final public function setTwigGlobals(Request $request): void $twig = $this->container->get('twig'); \assert($twig instanceof Environment); - $twig->addGlobal('admin', $this->admin); + try { + $twig->addGlobal('admin', $this->admin); - if ($this->isXmlHttpRequest($request)) { - $baseTemplate = $this->templateRegistry->getTemplate('ajax'); - } else { - $baseTemplate = $this->templateRegistry->getTemplate('layout'); - } + if ($this->isXmlHttpRequest($request)) { + $baseTemplate = $this->templateRegistry->getTemplate('ajax'); + } else { + $baseTemplate = $this->templateRegistry->getTemplate('layout'); + } - $twig->addGlobal('base_template', $baseTemplate); + $twig->addGlobal('base_template', $baseTemplate); + } catch (\LogicException) { + } } /**