vendor/bitbag/shipping-export-plugin/src/EventListener/Grid/AdminShippingGatewayGridEventListener.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file was created by developers working at BitBag
  4.  * Do you need more information about us and what we do? Visit our https://bitbag.io website!
  5.  * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
  6. */
  7. declare(strict_types=1);
  8. namespace BitBag\SyliusShippingExportPlugin\EventListener\Grid;
  9. use Sylius\Component\Grid\Event\GridDefinitionConverterEvent;
  10. final class AdminShippingGatewayGridEventListener
  11. {
  12.     /** @var array */
  13.     private $shippingGateways;
  14.     public function __construct(array $shippingGateways)
  15.     {
  16.         $this->shippingGateways $shippingGateways;
  17.     }
  18.     public function editActionLinks(GridDefinitionConverterEvent $event): void
  19.     {
  20.         $grid $event->getGrid();
  21.         $actions $grid->getActions('main');
  22.         if (!isset($actions['create'])) {
  23.             return;
  24.         }
  25.         $createAction $actions['create'];
  26.         $options $createAction->getOptions();
  27.         foreach ($this->shippingGateways as $shippingGatewayType => $shippingGatewayLabel) {
  28.             $options['links'][$shippingGatewayType] = [
  29.                 'label' => $shippingGatewayLabel,
  30.                 'icon' => 'plus',
  31.                 'route' => 'bitbag_admin_shipping_gateway_create',
  32.                 'parameters' => [
  33.                     'code' => $shippingGatewayType,
  34.                 ],
  35.             ];
  36.         }
  37.         $createAction->setOptions($options);
  38.     }
  39. }