vendor/ibexa/product-catalog/src/bundle/EventSubscriber/UpdateAvailabilityAfterProductCodeChange.php line 31

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace Ibexa\Bundle\ProductCatalog\EventSubscriber;
  8. use Ibexa\Contracts\ProductCatalog\Events\ProductCodeChangedEvent;
  9. use Ibexa\ProductCatalog\Local\Persistence\Legacy\ProductAvailability\HandlerInterface;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. final class UpdateAvailabilityAfterProductCodeChange implements EventSubscriberInterface
  12. {
  13.     private HandlerInterface $handler;
  14.     public function __construct(HandlerInterface $handler)
  15.     {
  16.         $this->handler $handler;
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             ProductCodeChangedEvent::class => 'updateProductCodeForAvailability',
  22.         ];
  23.     }
  24.     public function updateProductCodeForAvailability(ProductCodeChangedEvent $event): void
  25.     {
  26.         $this->handler->updateProductCode($event->getNewCode(), $event->getOldCode());
  27.     }
  28. }