Update extending pages (EventSubscriberInterface)#172
Update extending pages (EventSubscriberInterface)#172dennisameling wants to merge 3 commits intomainfrom
Conversation
The event `PageSendEvent` doesn't exist and should be `PageDisplayEvent`
|
@escopecz would you mind checking this? I find it a bit tricky to come up with a good example here, since some major refactoring was done in Mautic 3.x. I had to dive into some of Mautic's internals to come up with this example. |
| { | ||
| // Add page tokens | ||
| $content = $this->templating->render('HelloWorldBundle:SubscribedEvents\PageToken:token.html.php'); | ||
| $event->addTokenSection('helloworld.token', 'plugin.helloworld.header', $content); |
There was a problem hiding this comment.
This function was deleted in Mautic 3.0.0, without any hint as to what should be used instead. $event->addToken() seems to do the job in my testing.
There was a problem hiding this comment.
@dennisameling this method was removed over 5 years ago https://github.com/mautic-inc/mautic-cloud/commit/5ac67e5293eadfa551f21023a6345196fa6c861c#diff-ecfcb8a8d5446acbe2a7dfe89af7f3eb6126f89f4b939e4a522461b0a25057df
Look at for example https://github.com/mautic/mautic/blob/staging/app/bundles/AssetBundle/EventListener/BuilderSubscriber.php which is a good example how to work with tokens.
This is partly work for #159, but it doesn't close the issue yet (there are more examples where the removed
CommonSubscriberis used).This PR fixes one of the cases where
CommonSubscribershould be removed.Inspiration for this was partly taken from https://github.com/mautic/mautic/blob/staging/app/bundles/FormBundle/EventListener/PageSubscriber.php