src/App/EventListener/Central/ClientPostCreateListener.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\EventListener\Central;
  3. use App\Entity\Central\Client\Client;
  4. use App\EventListener\GenericEvent;
  5. use App\Service\Central\Client\ClientManager;
  6. use App\Service\ShellExecManager;
  7. use Symfony\Bundle\FrameworkBundle\Console\Application;
  8. use Symfony\Component\Console\Input\ArrayInput;
  9. use Symfony\Component\Console\Output\BufferedOutput;
  10. use Symfony\Component\HttpKernel\KernelInterface;
  11. class ClientPostCreateListener
  12. {
  13.     private $kernel;
  14.     private $shellExecManager;
  15.     private $clientManager;
  16.     public function __construct(ShellExecManager $shellExecManagerKernelInterface $kernelClientManager $clientManager)
  17.     {
  18.         $this->kernel $kernel;
  19.         $this->shellExecManager $shellExecManager;
  20.         $this->clientManager $clientManager;
  21.     }
  22.     public function createDatabase(GenericEvent $genericEvent)
  23.     {
  24.         $client $genericEvent->getSubject();
  25.         if (!$client instanceof Client || $client->getId() === null) {
  26.             return;
  27.         }
  28.         $application = new Application($this->kernel);
  29.         $application->setAutoExit(false);
  30.         $input = new ArrayInput([
  31.             'command' => 'doctrine:schema:update',
  32.             '--force' => true,
  33.             '--dump-sql' => true,
  34.             '--client' => $client->getId()
  35.         ]);
  36.         $output = new BufferedOutput();
  37.         $application->run($input$output);
  38. //        $this->clientManager->resolveUser($client);
  39.     }
  40. }