<?php
namespace App\EventSubscribers\Main;
use App\Events\Main\Pack\AddedNonEligiblePackEvent;
use App\Services\FixedNotificationManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class CartSubscriber
* @package App\EventSubscribers\Main
*/
class PackSubscriber implements EventSubscriberInterface
{
const
PACK_NON_ELIGIBLE_EVENT = 'pack.nonEligible'
;
/**
* @var FixedNotificationManager
*/
private FixedNotificationManager $fixedNotificationManager;
/**
* PackSubscriber constructor.
* @param FixedNotificationManager $fixedNotificationManager
*/
public function __construct(FixedNotificationManager $fixedNotificationManager)
{
$this->fixedNotificationManager = $fixedNotificationManager;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return array(
self::PACK_NON_ELIGIBLE_EVENT => "addedPackNonEligible"
);
}
/**
* @param AddedNonEligiblePackEvent $event
*/
public function addedPackNonEligible(AddedNonEligiblePackEvent $event)
{
$packCondition = $event->getCondition();
$this->fixedNotificationManager->addNotification($packCondition->getErrorMessage());
}
}