src/EventSubscriber/Delete/PackagesConsolidationReadinessSubscriber.php line 29

  1. <?php
  2. namespace App\EventSubscriber\Delete;
  3. use ApiPlatform\Validator\ValidatorInterface;
  4. use App\Event\Delete\BoxReadyForConsolidationEvent;
  5. use App\Event\Expediting\ShippingSegmentEventInterface;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\HttpKernel\KernelInterface;
  9. readonly class PackagesConsolidationReadinessSubscriber implements EventSubscriberInterface
  10. {
  11.     use BoxMoverTrait;
  12.     public function __construct(
  13.         private KernelInterface $kernel,
  14.         private EntityManagerInterface $entityManager,
  15.         private ValidatorInterface $validator,
  16.     ) {}
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             BoxReadyForConsolidationEvent::IDENTIFIER => ['handle', -100],
  21.         ];
  22.     }
  23.     public function handle(ShippingSegmentEventInterface $event): void
  24.     {
  25.         $shippingSegment $event->getShippingSegment();
  26.         $this->move($shippingSegment);
  27.     }
  28. }