src/App/EventListener/Custom/VinoLevice/PostListener.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\EventListener\Custom\VinoLevice;
  3. use App\Entity\Central\Client\Client;
  4. use App\Entity\Client\Store\StoreCentral;
  5. use App\EventListener\GenericEvent;
  6. use App\Model\ShellExec;
  7. use App\Service\ShellExecManager;
  8. use App\Utils\ClientUtils;
  9. class PostListener
  10. {
  11.     private ShellExecManager $shellExecManager;
  12.     public function __construct(ShellExecManager $shellExecManager)
  13.     {
  14.         $this->shellExecManager $shellExecManager;
  15.     }
  16.     public function postStoreCentralCreate(GenericEvent $genericEvent)
  17.     {
  18.         /** @var StoreCentral $entity */
  19.         $entity $genericEvent->getSubject();
  20.         if (!$entity instanceof StoreCentral) {
  21.             return;
  22.         }
  23.         $this->isClient($genericEvent->getAppManager()->getClient());
  24.         $shellExec = new ShellExec('vinolevice:export_store_central''--id=' $entity->getId() . ' --kernel=vinolevice');
  25.         $this->shellExecManager->runShellExec($shellExectrue);
  26.     }
  27.     private function isClient($client)
  28.     {
  29.         if (!$client instanceof Client || $client->getCode() !== ClientUtils::VINOLEVICE) {
  30.             throw new \Exception('Bad client');
  31.         }
  32.     }
  33. }