-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstallCommand.php
More file actions
47 lines (40 loc) · 2.04 KB
/
InstallCommand.php
File metadata and controls
47 lines (40 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace CommonGateway\CoreBundle\Command;
use CommonGateway\CoreBundle\Service\InstallationService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class InstallCommand extends Command
{
protected static $defaultName = 'commongateway:install';
private $installationService;
public function __construct(InstallationService $installationService)
{
$this->installationService = $installationService;
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('bundle', InputArgument::REQUIRED, 'The bundle that you want to install')
->addArgument('data', InputArgument::OPTIONAL, 'Load (example) data set(s) from the bundle')
->addOption('schema', 'sa', InputOption::VALUE_OPTIONAL, 'Load an (example) data set from the bundle', false)
->addOption('script', 'sp', InputOption::VALUE_OPTIONAL, 'Load an (example) data set from the bundle', false)
->addOption('unsafe', 'u', InputOption::VALUE_OPTIONAL, 'Update existing schema\'s and data sets', false)
->setDescription('This command runs the installation service on a commongateway bundle')
->setHelp('This command allows you to run further installation an configuration actions afther installing a plugin');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->installationService->setStyle(new SymfonyStyle($input, $output));
return $this->installationService->install($input->getArgument('bundle'), [
'data' => $input->getArgument('data'),
'noSchema' => $input->getOption('schema'),
'script' => $input->getOption('script'),
'unsafe' => $input->getOption('unsafe'),
]);
}
}