From d55acff661c58293bf569744c057e0dad6a94ea0 Mon Sep 17 00:00:00 2001 From: Obinna Ikeh Date: Sat, 23 Nov 2024 23:28:15 +0100 Subject: [PATCH 1/2] improv: ensure all commands that extend abscommand has company id option --- .../Commands/AbstractSharedCommand.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/backend/app/Console/Commands/AbstractSharedCommand.php b/src/backend/app/Console/Commands/AbstractSharedCommand.php index 0aec48a4c..5b19cae69 100644 --- a/src/backend/app/Console/Commands/AbstractSharedCommand.php +++ b/src/backend/app/Console/Commands/AbstractSharedCommand.php @@ -16,6 +16,23 @@ abstract class AbstractSharedCommand extends Command protected int $EXECUTION_TYPE = self::EXECUTE_FOR_ALL; + + /** + * Configure the command + */ + protected function configure(): void + { + parent::configure(); + + $this->addOption( + 'company-id', + null, + \Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, + 'The ID of the company to run the command for. If not provided, runs for all companies.' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) { /** @var DatabaseProxyManagerService $databaseProxyManagerService */ @@ -62,7 +79,7 @@ private function runForCompany( InputInterface $input, OutputInterface $output, ): void { - $this->info('Running '.$this->name.' for company ID : '.$companyId); + $this->info('Running ' . $this->name . ' for company ID : ' . $companyId); $databaseProxyManagerService->runForCompany($companyId, function () use ($input, $output) { parent::execute($input, $output); }); From 3fd599c000309815ba131945c4e168b4d07a9b65 Mon Sep 17 00:00:00 2001 From: Obinna Ikeh Date: Mon, 25 Nov 2024 19:14:30 +0100 Subject: [PATCH 2/2] fix: lint warnings --- src/backend/app/Console/Commands/AbstractSharedCommand.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/app/Console/Commands/AbstractSharedCommand.php b/src/backend/app/Console/Commands/AbstractSharedCommand.php index 5b19cae69..43c617c9a 100644 --- a/src/backend/app/Console/Commands/AbstractSharedCommand.php +++ b/src/backend/app/Console/Commands/AbstractSharedCommand.php @@ -16,9 +16,8 @@ abstract class AbstractSharedCommand extends Command protected int $EXECUTION_TYPE = self::EXECUTE_FOR_ALL; - /** - * Configure the command + * Configure the command. */ protected function configure(): void { @@ -32,7 +31,6 @@ protected function configure(): void ); } - protected function execute(InputInterface $input, OutputInterface $output) { /** @var DatabaseProxyManagerService $databaseProxyManagerService */ @@ -79,7 +77,7 @@ private function runForCompany( InputInterface $input, OutputInterface $output, ): void { - $this->info('Running ' . $this->name . ' for company ID : ' . $companyId); + $this->info('Running '.$this->name.' for company ID : '.$companyId); $databaseProxyManagerService->runForCompany($companyId, function () use ($input, $output) { parent::execute($input, $output); });