src/Aqarmap/Bundle/NotificationBundle/UserSubscriber.php line 41

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\NotificationBundle;
  3. use Aqarmap\Bundle\NotificationBundle\Types\UserWasSignup;
  4. use FOS\UserBundle\Event\FilterUserResponseEvent;
  5. use FOS\UserBundle\FOSUserEvents;
  6. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class UserSubscriber implements EventSubscriberInterface
  9. {
  10.     /**
  11.      * EventDispatcherInterface instance.
  12.      *
  13.      * @var EventDispatcherInterface
  14.      */
  15.     public $dispatcher;
  16.     /**
  17.      * Create a user subscriber instance.
  18.      */
  19.     public function __construct(EventDispatcherInterface $dispatcher)
  20.     {
  21.         $this->dispatcher $dispatcher;
  22.     }
  23.     /**
  24.      * Register the listeners for the subscriber.
  25.      */
  26.     public static function getSubScribedEvents()
  27.     {
  28.         return [
  29.             FOSUserEvents::REGISTRATION_COMPLETED => 'onRegistrationCompleted',
  30.         ];
  31.     }
  32.     /**
  33.      * Send notification when registration completed.
  34.      */
  35.     public function onRegistrationCompleted(FilterUserResponseEvent $event): void
  36.     {
  37.         $this->dispatcher->dispatch(new UserWasSignup($event->getUser()), 'user.was.signup');
  38.     }
  39. }