[CORE][Controller] Allow plugins to override the Twig templates

This commit is contained in:
Hugo Sales 2021-10-28 14:29:34 +01:00
parent 18aeeb3850
commit c352e40518
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -122,6 +122,7 @@ abstract class Controller extends AbstractController implements EventSubscriberI
$this->vars = array_merge_recursive($this->vars, $response); $this->vars = array_merge_recursive($this->vars, $response);
$template = \array_key_exists('_template', $this->vars) ? $this->vars['_template'] : null; $template = \array_key_exists('_template', $this->vars) ? $this->vars['_template'] : null;
Event::handle('OverrideTemplate', [$this->vars, &$template]); // Allow plugins to replace the template used for anything
unset($this->vars['_template'], $response['_template']); unset($this->vars['_template'], $response['_template']);
// Respond in the most preferred acceptable content type // Respond in the most preferred acceptable content type