This repository was archived by the owner on Sep 26, 2024. It is now read-only.
Description In Mautic 3, the CommonSubscriber is removed, which was the recommended way to listen for events in Mautic 2.x. See UPGRADE-3.0.md for details.
The docs will need an update to reflect this change.
Previously, the code would have looked like:
<?php
namespace MauticPlugin \MyPluginBundle \EventListener ;
use Mautic \LeadBundle \LeadEvents ;
use Mautic \LeadBundle \Event \LeadEvent ;
use Mautic \CoreBundle \EventListener \CommonSubscriber ;
class LeadPostSaveSubscriber extends CommonSubscriber {
/**
* @return array
*/
static public function getSubscribedEvents ()
{
return array (
LeadEvents::LEAD_POST_SAVE => array ('onLeadPostSave ' , 0 ),
);
}
public function onLeadPostSave (LeadEvent $ event )
{
$ lead = $ event ->getLead ();
// Some logic here
}
}
Now, the code should look like:
<?php
namespace MauticPlugin \MyPluginBundle \EventListener ;
use Mautic \LeadBundle \LeadEvents ;
use Mautic \LeadBundle \Event \LeadEvent ;
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
class LeadPostSaveSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
static public function getSubscribedEvents ()
{
return array (
LeadEvents::LEAD_POST_SAVE => array ('onLeadPostSave ' , 0 ),
);
}
public function onLeadPostSave (LeadEvent $ event )
{
$ lead = $ event ->getLead ();
// Some logic here
}
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource .
Reactions are currently unavailable