From 55d6dad2bd6bb797d1cb3588c3f37bf618fc1ce2 Mon Sep 17 00:00:00 2001 From: "paul@gh" Date: Wed, 6 Jul 2022 13:22:31 +0200 Subject: [PATCH 1/3] Fix "employee" option not found --- src/Command.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Command.php b/src/Command.php index 68850134..e68ddda8 100644 --- a/src/Command.php +++ b/src/Command.php @@ -33,12 +33,17 @@ abstract class Command extends ContainerAwareCommand { /** @var \Symfony\Component\Console\Style\SymfonyStyle */ protected $io; + + protected function configure() + { + $this->addOption('employee', '-em', InputOption::VALUE_REQUIRED, 'Specify employee context (id).', null); + + parent::configure(); + } protected function initialize(InputInterface $input, OutputInterface $output): void { $container = $this->getContainer(); - $commandDefinition = $this->getDefinition(); - $commandDefinition->addOption(new InputOption('employee', '-em', InputOption::VALUE_REQUIRED, 'Specify employee context (id).', null)); $container->get('fop.console.console_loader')->loadConsoleContext($input); From cce08a04f1befc47f521192bedd4a994cd31e7e7 Mon Sep 17 00:00:00 2001 From: "paul@gh" Date: Fri, 9 Sep 2022 17:29:59 +0200 Subject: [PATCH 2/3] Move addOption "employee" to constructor instead of configure The configure() method is often overridden by Commands without calling the parent method. Moving to constructor is safer. --- src/Command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Command.php b/src/Command.php index e68ddda8..e0f30ade 100644 --- a/src/Command.php +++ b/src/Command.php @@ -34,11 +34,11 @@ abstract class Command extends ContainerAwareCommand /** @var \Symfony\Component\Console\Style\SymfonyStyle */ protected $io; - protected function configure() + public function __construct(string $name = null) { + parent::__construct($name); + $this->addOption('employee', '-em', InputOption::VALUE_REQUIRED, 'Specify employee context (id).', null); - - parent::configure(); } protected function initialize(InputInterface $input, OutputInterface $output): void From 727fb5f3f246a42e6ee84aba6048f02bc03f3c1c Mon Sep 17 00:00:00 2001 From: "paul@gh" Date: Mon, 12 Sep 2022 17:31:24 +0200 Subject: [PATCH 3/3] Fix php cs errors --- src/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command.php b/src/Command.php index e0f30ade..254aa2e5 100644 --- a/src/Command.php +++ b/src/Command.php @@ -33,7 +33,7 @@ abstract class Command extends ContainerAwareCommand { /** @var \Symfony\Component\Console\Style\SymfonyStyle */ protected $io; - + public function __construct(string $name = null) { parent::__construct($name);