Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| InstallRunCommand | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| configure | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Console\Command; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use Symfony\Component\Console\Command\Command; |
| 12 | use Symfony\Component\Console\Input\InputInterface; |
| 13 | use Symfony\Component\Console\Input\InputOption; |
| 14 | use Symfony\Component\Console\Output\OutputInterface; |
| 15 | |
| 16 | /** |
| 17 | * System Installation & Reset Console Command. |
| 18 | * |
| 19 | * @package App\Core\Console\Command |
| 20 | */ |
| 21 | final class InstallRunCommand extends Command |
| 22 | { |
| 23 | /** |
| 24 | * InstallRunCommand constructor. |
| 25 | * |
| 26 | * @param string $basePath Application base path. |
| 27 | */ |
| 28 | public function __construct(private readonly string $basePath) |
| 29 | { |
| 30 | parent::__construct('install:run'); |
| 31 | } |
| 32 | |
| 33 | /** {@inheritdoc} */ |
| 34 | protected function configure(): void |
| 35 | { |
| 36 | $this->setDescription('Executes database installation, schema deployment and technical setup.') |
| 37 | ->addOption('all', null, InputOption::VALUE_NONE, 'Run complete full database reinstallation reset.'); |
| 38 | } |
| 39 | |
| 40 | /** {@inheritdoc} */ |
| 41 | protected function execute(InputInterface $input, OutputInterface $output): int |
| 42 | { |
| 43 | $output->writeln('<info>Triggering Ammonly App Admin Installer...</info>'); |
| 44 | $installScript = escapeshellarg($this->basePath . '/bin/install'); |
| 45 | $flag = $input->getOption('all') ? ' --all' : ''; |
| 46 | passthru("php {$installScript}{$flag}", $returnCode); |
| 47 | |
| 48 | return $returnCode === 0 ? Command::SUCCESS : Command::FAILURE; |
| 49 | } |
| 50 | } |