Skip to content

Commit

Permalink
Added command alias
Browse files Browse the repository at this point in the history
  • Loading branch information
kathibeepboop committed Jul 7, 2022
1 parent 3d4c7d9 commit 5ebbff8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Command/CreateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Fluxter\SaasProviderBundle\Model\Event\ConsoleClientCreationEvent;
use Fluxter\SaasProviderBundle\Model\TenantInterface;
use Fluxter\SaasProviderBundle\Service\TenantService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand All @@ -17,14 +18,15 @@

class CreateClientCommand extends Command
{
protected static $defaultName = 'fluxter:saas:provider:create-client';
protected static $defaultName = '';

private string $saasClientEntity;

public function __construct(
ContainerInterface $container,
private EntityManagerInterface $em,
private EventDispatcherInterface $eventDispatcher
private readonly EntityManagerInterface $em,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly TenantService $tenantService
) {
parent::__construct();
$this->saasClientEntity = $container->getParameter('saas_provider.client_entity');
Expand All @@ -34,6 +36,11 @@ protected function configure()
{
$this
->setDescription('Creates a new SaaS client')
->setName("fx:saas:create")
->setAliases([
"fluxter:saas:provider:create-client",
"fx:saas:provider:create-client"
])
->addArgument('url', InputArgument::REQUIRED, 'The url without www and http')
;
}
Expand All @@ -43,6 +50,7 @@ protected function execute(\Symfony\Component\Console\Input\InputInterface $inpu
/** @var TenantInterface */
$client = new $this->saasClientEntity();
$client->setUrl($input->getArgument('url'));
$this->tenantService->setTenant($client);

$event = new ConsoleClientCreationEvent($client, new SymfonyStyle($input, $output));
$this->eventDispatcher->dispatch($event);
Expand Down

0 comments on commit 5ebbff8

Please sign in to comment.