vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/CatalogPromotion/EventListener/CatalogPromotionEventListener.php line 27

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\CoreBundle\CatalogPromotion\EventListener;
  12. use Sylius\Bundle\CoreBundle\CatalogPromotion\Announcer\CatalogPromotionAnnouncerInterface;
  13. use Sylius\Component\Core\Model\CatalogPromotionInterface;
  14. use Symfony\Component\EventDispatcher\GenericEvent;
  15. use Webmozart\Assert\Assert;
  16. final class CatalogPromotionEventListener
  17. {
  18.     public function __construct(private CatalogPromotionAnnouncerInterface $catalogPromotionAnnouncer)
  19.     {
  20.     }
  21.     public function handleCatalogPromotionCreatedEvent(GenericEvent $event): void
  22.     {
  23.         /** @var CatalogPromotionInterface $catalogPromotion */
  24.         $catalogPromotion $event->getSubject();
  25.         Assert::isInstanceOf($catalogPromotionCatalogPromotionInterface::class);
  26.         $this->catalogPromotionAnnouncer->dispatchCatalogPromotionCreatedEvent($catalogPromotion);
  27.     }
  28.     public function handleCatalogPromotionUpdatedEvent(GenericEvent $event): void
  29.     {
  30.         /** @var CatalogPromotionInterface $catalogPromotion */
  31.         $catalogPromotion $event->getSubject();
  32.         Assert::isInstanceOf($catalogPromotionCatalogPromotionInterface::class);
  33.         $this->catalogPromotionAnnouncer->dispatchCatalogPromotionUpdatedEvent($catalogPromotion);
  34.     }
  35. }