vendor/bluue/prestashop-connector-bundle/src/EventSubscriber/OrderOptionsEditCarrierSubscriber.php line 49

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Thomas HERISSON (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\PrestashopConnectorBundle\EventSubscriber;
  9. use ReflectionClass;
  10. use App\Services\CheckBundleInstall;
  11. use Symfony\Component\Messenger\MessageBusInterface;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Bluue\PrestashopConnectorBundle\Message\UpdateOrderOptionsCarrierToPrestaMessage;
  14. class OrderOptionsEditCarrierSubscriber implements EventSubscriberInterface
  15. {
  16.     /**
  17.      * @var MessageBusInterface $messageBus
  18.      */
  19.     protected MessageBusInterface $messageBus;
  20.     public function __construct(MessageBusInterface $messageBus)
  21.     {
  22.         $this->messageBus $messageBus;
  23.     }
  24.     /**
  25.      * @return string[]
  26.      */
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         if (CheckBundleInstall::exist('shipments-bundle')) {
  30.             $reflectionClass = new ReflectionClass('Bluue\ShipmentsBundle\Event\OrderOptionsEditCarrierEvent');
  31.             return [
  32.                 $reflectionClass->getConstant('POST_SUBMIT') => 'postSubmit'
  33.             ];
  34.         }
  35.         return [];
  36.     }
  37.     /**
  38.      * @param object $event
  39.      * @return void
  40.      */
  41.     public function postSubmit(object $event): void
  42.     {
  43.         $this->messageBus->dispatch(
  44.             new UpdateOrderOptionsCarrierToPrestaMessage($event->getOrderOptions()->getId()->toRfc4122())
  45.         );
  46.     }
  47. }