src/App/EventListener/Custom/Gonarex/StoreWarehouseDuplicityListener.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\EventListener\Custom\Gonarex;
  3. use App\Entity\Central\Client\Client;
  4. use App\Entity\Client\Store\StoreHeader;
  5. use App\EventListener\GenericEvent;
  6. use App\Model\ShellExec;
  7. use App\Service\AppManager;
  8. use App\Service\ShellExecManager;
  9. use App\Utils\ClientUtils;
  10. class StoreWarehouseDuplicityListener
  11. {
  12.     private AppManager $appManager;
  13.     private ShellExecManager $shellExecManager;
  14.     public function __construct(AppManager $appManagerShellExecManager $shellExecManager)
  15.     {
  16.         $this->appManager $appManager;
  17.         $this->shellExecManager $shellExecManager;
  18.     }
  19.     public function confirm(GenericEvent $genericEvent): void
  20.     {
  21.         $client $this->appManager->getClient();
  22.         if (!$client instanceof Client || $client->getCode() !== ClientUtils::GONAREX) {
  23.             return;
  24.         }
  25.         $storeHeader $genericEvent->getSubject();
  26.         if (!$storeHeader instanceof StoreHeader || $storeHeader->getType() !== StoreHeader::STORE_HEADER_WAREHOUSE_RECEIPT) {
  27.             return;
  28.         }
  29.         $shellExec = new ShellExec('gonarex:duplicity_warehouse_receipt''--id=' $storeHeader->getId() . ' --kernel=custom');
  30.         $this->shellExecManager->runShellExec($shellExectrue);
  31.     }
  32. }