src/EventSubscribers/Main/PackSubscriber.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscribers\Main;
  3. use App\Events\Main\Pack\AddedNonEligiblePackEvent;
  4. use App\Services\FixedNotificationManager;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * Class CartSubscriber
  8.  * @package App\EventSubscribers\Main
  9.  */
  10. class PackSubscriber implements EventSubscriberInterface
  11. {
  12.     const
  13.         PACK_NON_ELIGIBLE_EVENT 'pack.nonEligible'
  14.     ;
  15.     /**
  16.      * @var FixedNotificationManager
  17.      */
  18.     private FixedNotificationManager $fixedNotificationManager;
  19.     /**
  20.      * PackSubscriber constructor.
  21.      * @param FixedNotificationManager $fixedNotificationManager
  22.      */
  23.     public function __construct(FixedNotificationManager $fixedNotificationManager)
  24.     {
  25.         $this->fixedNotificationManager $fixedNotificationManager;
  26.     }
  27.     /**
  28.      * @return array
  29.      */
  30.     public static function getSubscribedEvents()
  31.     {
  32.         return array(
  33.             self::PACK_NON_ELIGIBLE_EVENT => "addedPackNonEligible"
  34.         );
  35.     }
  36.     /**
  37.      * @param AddedNonEligiblePackEvent $event
  38.      */
  39.     public function addedPackNonEligible(AddedNonEligiblePackEvent $event)
  40.     {
  41.         $packCondition $event->getCondition();
  42.         $this->fixedNotificationManager->addNotification($packCondition->getErrorMessage());
  43.     }
  44. }