From 3adfeb366ca9720ff99d33edebdd063dd21651e2 Mon Sep 17 00:00:00 2001 From: David mattei Date: Thu, 11 Jul 2024 20:57:10 +0200 Subject: [PATCH] refactor: overwrite render method in controller trait --- .../src/Controller/CoreControllerTrait.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/EMS/core-bundle/src/Controller/CoreControllerTrait.php b/EMS/core-bundle/src/Controller/CoreControllerTrait.php index abc8752cc..7dde96bbd 100644 --- a/EMS/core-bundle/src/Controller/CoreControllerTrait.php +++ b/EMS/core-bundle/src/Controller/CoreControllerTrait.php @@ -6,6 +6,9 @@ use Symfony\Component\Form\Form; use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\Response; + +use function Symfony\Component\String\u; trait CoreControllerTrait { @@ -19,4 +22,18 @@ protected function getClickedButtonName(FormInterface $form): ?string return $clickedButton instanceof FormInterface ? $clickedButton->getName() : null; } + + /** + * @param array $parameters + */ + protected function render(string $view, array $parameters = [], ?Response $response = null): Response + { + $templateNamespace = parent::getParameter('ems_core.template_namespace'); + + if (\is_string($templateNamespace) && 'EMSCore' !== $templateNamespace) { + $view = u($view)->replaceMatches('/^@EMSCore/', '@'.$templateNamespace)->toString(); + } + + return parent::render($view, $parameters, $response); + } }