I am trying to migrate one plugin from Mautic 4 and Mautic 5, I basically fixed everything except the replacing of custom templates.
Now in Mautic 4 we replaced the templates by subscribing like this:
public static function getSubscribedEvents()
{
return [
CoreEvents::VIEW_INJECT_CUSTOM_TEMPLATE => [
['replaceTemplates', 0],
],
];
}
The thing I have inspected the code base of Mautic. This event is not dispatched anywhere anymore, in fact CoreEvents::VIEW_INJECT_CUSTOM_TEMPLATE only occurs twice in the code base.
How would one replace the templates now (maybe Kernel::VIEW)?
Great question! That was part of the PhpEngine. PHP templates were dropped in Symfony 4. So Mautic 5 had to drop the support for it as well in order to run on supported Symfony version.
I guess nobody noticed that the CoreEvents::VIEW_INJECT_CUSTOM_TEMPLATE event is no longer triggered anywhere.
KernelEvents::VIEW looks like the next best thing. I couldn’t find any events dispatched by the Twig dependencies.
I’ll create a PR to remove this dead code and document it in the upgrading doc.