Skip to content

Commit

Permalink
Improve Initialize command
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Mar 29, 2024
1 parent 9a61df5 commit 30431ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/docker/php/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then

if [ "$APP_INIT" != 'false' ]; then
echo "Initializing the gateway"
bin/console commongateway:initialize
bin/console commongateway:initialize --cache-warmup
fi

fi
Expand Down
28 changes: 20 additions & 8 deletions api/src/Command/InitializationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ protected function configure(): void
$this
->addOption('bundle', 'b', InputOption::VALUE_OPTIONAL, 'The bundle that you want to install (install only that bundle)')
->addOption('data', 'd', InputOption::VALUE_OPTIONAL, 'Load (example) data set(s) from the bundle', false)
->addOption('skip-schema', 'sa', InputOption::VALUE_OPTIONAL, 'Don\'t update schema\'s during upgrade', false)
->addOption('skip-script', 'sp', InputOption::VALUE_OPTIONAL, 'Don\'t execute installation scripts during upgrade', false)
->addOption('unsafe', 'u', InputOption::VALUE_OPTIONAL, 'Delete data that is not present in the test data', false)
->addOption('skip-schema', 's', InputOption::VALUE_OPTIONAL, 'Don\'t update schema\'s during upgrade', false)
->addOption('skip-script', 'x', InputOption::VALUE_OPTIONAL, 'Don\'t execute installation scripts during upgrade', false)
->addOption('cache-warmup', 'c', InputOption::VALUE_OPTIONAL, 'Include running a cache:warmup at the end', false)
//todo?
// ->addOption('unsafe', 'u', InputOption::VALUE_OPTIONAL, 'Delete data that is not present in the test data', false)
// the short description shown while running "php bin/console list"
->setDescription('Facilitates the initialization of the gateway and checks configuration')

Expand All @@ -86,11 +87,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$config = [];
$config['bundle'] = $input->getOption('bundle');
$config['data'] = $input->getOption('data');
$config['skip-schema'] = $input->getOption('skip-schema');
$config['skip-script'] = $input->getOption('skip-script');
$config['unsafe'] = $input->getOption('unsafe');
$config['cache-warmup'] = $input->getOption('cache-warmup');
if ($input->getOption('data') !== false) {
$config['data'] = true;
}
if ($input->getOption('skip-schema') !== false) {
$config['skip-schema'] = true;
}
if ($input->getOption('skip-script') !== false) {
$config['skip-script'] = true;
}
if ($input->getOption('cache-warmup') !== false) {
$config['cache-warmup'] = true;
}
// if ($input->getOption('unsafe') !== false) {
// $config['unsafe'] = true;
// }

// Throw the event
$io->info('Throwing commongateway.pre.initialization event');
Expand Down Expand Up @@ -289,6 +300,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// In dev we also want to run the installer
//if( getenv("APP_ENV") == "dev"){
$io->section('Running installer');
echo json_encode($config);
$this->installationService->update($config, $io);
//}

Expand Down

0 comments on commit 30431ce

Please sign in to comment.