src/EventSubscriber/Media/NotificationSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * @since 1.0.0
  4.  * @copyright Copyright (C) 2020 ArtMedia. All rights reserved.
  5.  * @website http://artmedia.biz.pl
  6.  * @author Arkadiusz Tobiasz
  7.  * @email kontakt@artmedia.biz.pl
  8.  */
  9. namespace App\EventSubscriber\Media;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. use App\Events\Core\NotificationAddEvent;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. use App\Entity\Media\Credit;
  14. use App\Entity\Media\Photo;
  15. class NotificationSubscriber implements EventSubscriberInterface
  16. {
  17.     private $translator;
  18.     public function __construct(
  19.         TranslatorInterface $translator
  20.     ) {
  21.         $this->translator $translator;
  22.     }
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             NotificationAddEvent::NAME => 'onNotificationAddEvent',
  27.         ];
  28.     }
  29.     public function onNotificationAddEvent(NotificationAddEvent $event): void
  30.     {
  31.         $event->addNotification(Credit::NOTIFICATION$this->translator->trans('I get credited in someone else’s portfolio', [], 'email_notification'));
  32.         $event->addNotification(Credit::FOLLOW_NOTIFICATION$this->translator->trans('Someone I follow gets credited in someone’s image', [], 'email_notification'));
  33.         $event->addNotification(Photo::FOLLOW_NOTIFICATION$this->translator->trans('Someone I follow adds a new image', [], 'email_notification'));
  34.     }
  35. }