src/EventSubscriber/Order/ValidateReceivePhotosSubscriber.php line 30

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  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 App\EventSubscriber\Order;
  12. use App\Entity\Order\Order;
  13. use App\Entity\Order\OrderItemPhoto;
  14. use App\Message\ApplyPhotosReceiveTransitionMessage;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. use Symfony\Component\Messenger\MessageBusInterface;
  17. use Symfony\Component\Workflow\Event\Event;
  18. class ValidateReceivePhotosSubscriber implements EventSubscriberInterface
  19. {
  20.     public function __construct(
  21.         private MessageBusInterface $messageBus,
  22.     ) {
  23.     }
  24.     public function onCompleted(Event $event)
  25.     {
  26.         /** @var OrderItemPhoto $orderItemPhoto */
  27.         $orderItemPhoto $event->getSubject();
  28.         /** @var Order $order */
  29.         $order $orderItemPhoto->getOrderItem()->getOrder();
  30.         
  31.         $this->messageBus->dispatch(new ApplyPhotosReceiveTransitionMessage($order->getId()));
  32.     }
  33.     public static function getSubscribedEvents()
  34.     {
  35.         return [
  36.             'workflow.photo.completed.production' => 'onCompleted',
  37.         ];
  38.     }
  39. }