vendor/bluue/shipments-bundle/src/EventSubscriber/ConfigureListButtonsSubscriber.php line 50

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Bluue\ShipmentsBundle\EventSubscriber;
  4. use App\Event\MassManagementListButtonsEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\Routing\RouterInterface;
  7. use Symfony\Contracts\Translation\TranslatorInterface;
  8. class ConfigureListButtonsSubscriber implements EventSubscriberInterface
  9. {
  10.     /**
  11.      * @var RouterInterface
  12.      */
  13.     private RouterInterface $router;
  14.     /**
  15.      * @var TranslatorInterface
  16.      */
  17.     private TranslatorInterface $tr;
  18.     /**
  19.      * @param RouterInterface $router
  20.      * @param TranslatorInterface $tr
  21.      */
  22.     public function __construct(
  23.         RouterInterface $router,
  24.         TranslatorInterface $tr
  25.     ) {
  26.         $this->router $router;
  27.         $this->tr $tr;
  28.     }
  29.     /**
  30.      * @return string[]
  31.      */
  32.     public static function getSubscribedEvents(): array
  33.     {
  34.         return [
  35.             MassManagementListButtonsEvent::NAME => 'onLoad',
  36.         ];
  37.     }
  38.     /**
  39.      * @param MassManagementListButtonsEvent $event
  40.      * @return void
  41.      */
  42.     public function onLoad(MassManagementListButtonsEvent $event): void
  43.     {
  44.         if (str_starts_with($event->getListName(), '_shipments_bundle__order_list_')) {
  45.             $buttons $event->getButtons();
  46.             $btnOneBurstByOrder '<a href="' .
  47.                 $this->router->generate('shipments_bundle__burst_new_burst_from_orders', ['one_burst' => 1]) .
  48.                 '" class="btn btn-primary btn-sm bluue-modal-button mx-1" bluue-modal-label="' .
  49.                 $this->tr->trans('Create burst for each order', [], 'ShipmentsBundle') . '">' .
  50.                 $this->tr->trans('Create burst for each order', [], 'ShipmentsBundle') . '</a>';
  51.             $btnOrdersToBurst '<a href="' $this->router->generate('shipments_bundle__burst_new_burst_from_orders') .
  52.                 '" class="btn btn-primary btn-sm bluue-modal-button mx-1" bluue-modal-label="' .
  53.                 $this->tr->trans('Create burst from orders', [], 'ShipmentsBundle') . '">' .
  54.                 $this->tr->trans('Create burst from orders', [], 'ShipmentsBundle') . '</a>';
  55.             $buttons[] = [$btnOneBurstByOrder];
  56.             $buttons[] = [$btnOrdersToBurst];
  57.             $event->setButtons($buttons);
  58.         }
  59.     }
  60. }