Skip to content

Commit

Permalink
refactor: overwrite render method in controller trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei committed Jul 11, 2024
1 parent b027b18 commit 3adfeb3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions EMS/core-bundle/src/Controller/CoreControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -19,4 +22,18 @@ protected function getClickedButtonName(FormInterface $form): ?string

return $clickedButton instanceof FormInterface ? $clickedButton->getName() : null;
}

/**
* @param array<string, mixed> $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);
}
}

0 comments on commit 3adfeb3

Please sign in to comment.