<?php
namespace App\EventListener\Central;
use App\Entity\Central\Client\Client;
use App\EventListener\GenericEvent;
use App\Service\Central\Client\ClientManager;
use App\Service\ShellExecManager;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpKernel\KernelInterface;
class ClientPostCreateListener
{
private $kernel;
private $shellExecManager;
private $clientManager;
public function __construct(ShellExecManager $shellExecManager, KernelInterface $kernel, ClientManager $clientManager)
{
$this->kernel = $kernel;
$this->shellExecManager = $shellExecManager;
$this->clientManager = $clientManager;
}
public function createDatabase(GenericEvent $genericEvent)
{
$client = $genericEvent->getSubject();
if (!$client instanceof Client || $client->getId() === null) {
return;
}
$application = new Application($this->kernel);
$application->setAutoExit(false);
$input = new ArrayInput([
'command' => 'doctrine:schema:update',
'--force' => true,
'--dump-sql' => true,
'--client' => $client->getId()
]);
$output = new BufferedOutput();
$application->run($input, $output);
// $this->clientManager->resolveUser($client);
}
}