What is Mautic 5 way of injecting custom templates

Hi,

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)?

Thanks.

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.

Actually, I may have found a place where it could work as before. Would you mind giving it a test?

I will give it a test ASAP. Thank you. Will let you know when I make a review.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.