From 2cc2d567b902e9cedb761da8d7252a828bbdfdf5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 06:11:46 +0200 Subject: [PATCH 1/4] getTableHelper() --- .../Command/AbstractMagentoCommand.php | 20 ++++++++++++++++++- .../Command/Admin/User/ListCommand.php | 4 +--- src/N98/Magento/Command/Cache/ListCommand.php | 4 +--- .../Magento/Command/Cache/ReportCommand.php | 4 +--- .../Magento/Command/Cms/Block/ListCommand.php | 4 +--- .../Magento/Command/Config/DeleteCommand.php | 4 +--- src/N98/Magento/Command/Config/GetCommand.php | 4 +--- .../Command/Customer/CreateCommand.php | 4 +--- .../Command/Customer/CreateDummyCommand.php | 4 +--- .../Magento/Command/Customer/InfoCommand.php | 3 +-- .../Magento/Command/Customer/ListCommand.php | 4 +--- .../Command/Database/AbstractShowCommand.php | 4 +--- .../Magento/Command/Database/InfoCommand.php | 4 +--- .../Database/Maintain/CheckTablesCommand.php | 4 +--- .../Developer/EmailTemplate/UsageCommand.php | 4 +--- .../Module/Dependencies/AbstractCommand.php | 4 +--- .../Module/Dependencies/OnCommand.php | 4 +--- .../Command/Developer/Module/ListCommand.php | 4 +--- .../Developer/Module/Observer/ListCommand.php | 4 +--- .../Developer/Module/Rewrite/ListCommand.php | 5 ++--- .../Command/Developer/Theme/InfoCommand.php | 4 +--- .../Command/Developer/Theme/ListCommand.php | 4 +--- .../Command/Eav/Attribute/ListCommand.php | 4 +--- .../Command/Eav/Attribute/ViewCommand.php | 4 ++-- .../Magento/Command/Indexer/ListCommand.php | 4 +--- .../Command/Script/Repository/ListCommand.php | 4 +--- .../Magento/Command/System/CheckCommand.php | 4 +--- .../Command/System/Cron/HistoryCommand.php | 5 ++--- .../Command/System/Cron/ListCommand.php | 4 +--- .../Magento/Command/System/InfoCommand.php | 4 +--- .../System/Setup/CompareVersionsCommand.php | 4 +--- .../Command/System/Setup/RunCommand.php | 7 ++----- .../Store/Config/BaseUrlListCommand.php | 5 ++--- .../Command/System/Store/ListCommand.php | 5 ++--- .../Command/System/Website/ListCommand.php | 5 ++--- 35 files changed, 60 insertions(+), 103 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 69a043e0d..8575442db 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -18,6 +18,7 @@ use N98\Util\Console\Helper\MagentoHelper; use N98\Util\Console\Helper\ParameterHelper; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; +use N98\Util\Console\Helper\TableHelper; use N98\Util\OperatingSystem; use N98\Util\StringTyped; use RuntimeException; @@ -683,7 +684,7 @@ protected function createSubCommandFactory( * * @return $this */ - public function addFormatOption(): AbstractMagentoCommand + public function addFormatOption(): self { $this->addOption( 'format', @@ -694,18 +695,35 @@ public function addFormatOption(): AbstractMagentoCommand return $this; } + /** + * @return IoHelper + */ public function getIoHelper(): IoHelper { return $this->getHelper('io'); } + /** + * @return ParameterHelper + */ public function getParameterHelper(): ParameterHelper { return $this->getHelper('parameter'); } + /** + * @return QuestionHelper + */ public function getQuestionHelper(): QuestionHelper { return $this->getHelper('question'); } + + /** + * @return TableHelper + */ + public function getTableHelper(): TableHelper + { + return $this->getHelper('table'); + } } diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index b75da3ae7..91e288c46 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Admin\User; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -43,8 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = [$user->getId(), $user->getUsername(), $user->getEmail(), $user->getIsActive() ? 'active' : 'inactive']; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'username', 'email', 'status']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index a90359c94..cbae54ef4 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Cache; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -40,8 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = [$cacheCode, $cacheInfo['status'] ? 'enabled' : 'disabled']; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['code', 'status']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index a30b2724a..8f03a3111 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -4,7 +4,6 @@ use Enterprise_PageCache_Model_Cache; use Mage; -use N98\Util\Console\Helper\TableHelper; use RuntimeException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -98,8 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $headers[] = 'TAGS'; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders($headers) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index 5f961831b..13feaba95 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Cms\Block; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -63,8 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = [$cmsBlock->getData('block_id'), $cmsBlock->getData('identifier'), $cmsBlock->getData('title'), $cmsBlock->getData('is_active') ? 'active' : 'inactive', $storeIds]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['block_id', 'identifier', 'title', 'is_active', 'store_ids']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Config/DeleteCommand.php b/src/N98/Magento/Command/Config/DeleteCommand.php index 8f288f0e4..cd043f058 100644 --- a/src/N98/Magento/Command/Config/DeleteCommand.php +++ b/src/N98/Magento/Command/Config/DeleteCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Config; use Mage; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -84,8 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (count($deleted) > 0) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Deleted Path', 'Scope', 'Scope-ID']) ->setRows($deleted) diff --git a/src/N98/Magento/Command/Config/GetCommand.php b/src/N98/Magento/Command/Config/GetCommand.php index ac4733edd..d10cba8c8 100644 --- a/src/N98/Magento/Command/Config/GetCommand.php +++ b/src/N98/Magento/Command/Config/GetCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Config; -use N98\Util\Console\Helper\TableHelper; use Path; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -138,8 +137,7 @@ protected function renderAsTable(OutputInterface $output, $table, $format) $formattedTable[] = [$row['path'], $row['scope'], $row['scope_id'], $this->renderTableValue($row['value'], $format)]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders([Path::class, 'Scope', 'Scope-ID', 'Value']) ->setRows($formattedTable) diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index 59b8b6ec0..572e21d87 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Customer; use N98\Util\Console\Helper\ParameterHelper; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -102,8 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (!$outputPlain) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['email', 'password', 'firstname', 'lastname']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index bcbccb2dc..b2658fb11 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -5,7 +5,6 @@ use Faker\Factory; use Locale; use N98\Util\Console\Helper\ParameterHelper; -use N98\Util\Console\Helper\TableHelper; use N98\Util\Faker\Provider\Internet; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -136,8 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $res->commit(); if (!$outputPlain) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['email', 'password', 'firstname', 'lastname']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 8a541aee0..5f103f80a 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -78,8 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders([Attribute::class, 'Value']) ->setRows($table) diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index a5c2ac439..502b9ac7b 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Customer; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -67,8 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (count($table) > 0) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'email', 'firstname', 'lastname', 'website']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Database/AbstractShowCommand.php b/src/N98/Magento/Command/Database/AbstractShowCommand.php index a70efa618..23a54cc24 100644 --- a/src/N98/Magento/Command/Database/AbstractShowCommand.php +++ b/src/N98/Magento/Command/Database/AbstractShowCommand.php @@ -4,7 +4,6 @@ use Description; use N98\Util\Console\Helper\DatabaseHelper; -use N98\Util\Console\Helper\TableHelper; use N98\Util\Filesystem; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -164,8 +163,7 @@ protected function formatDesc($desc) */ protected function renderTable(array $header, array $rows) { - /** @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper->setHeaders($header) ->renderByFormat($this->_output, $rows, $this->_input->getOption('format')); } diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index e9bfed1da..c0eb5ad10 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -4,7 +4,6 @@ use InvalidArgumentException; use N98\Util\Console\Helper\DatabaseHelper; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -108,8 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $output->writeln((string) $settings[$settingArgument]); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Value']) ->renderByFormat($output, $rows, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php index ea367a1d9..9cbf4b498 100644 --- a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php +++ b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php @@ -5,7 +5,6 @@ use InvalidArgumentException; use N98\Magento\Command\AbstractMagentoCommand; use N98\Util\Console\Helper\DatabaseHelper; -use N98\Util\Console\Helper\TableHelper; use PDO; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -177,8 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $progress->finish(); } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Table', 'Operation', 'Type', 'Status']) ->renderByFormat($this->output, $tableOutput, $this->input->getOption('format')); diff --git a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php index 8415bebf9..9a9bf4b8f 100644 --- a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php +++ b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php @@ -6,7 +6,6 @@ use Mage_Adminhtml_Model_Email_Template; use Mage_Core_Model_Template; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Path; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -42,8 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $templates = $this->findEmailTemplates(); if (!empty($templates)) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'Name', 'Scope', 'Scope Id', Path::class]) ->renderByFormat($output, $templates, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php index db715eed1..d05023da5 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php @@ -5,7 +5,6 @@ use Exception; use InvalidArgumentException; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -69,8 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dependencies = $this->findModuleDependencies($moduleName, $recursive); if (!empty($dependencies)) { usort($dependencies, [$this, 'sortDependencies']); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) ->renderByFormat($output, $dependencies, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php index 8ff7e4280..2bcb34877 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -60,8 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('format') === null && count($dependencies) === 0) { $output->writeln(sprintf("Module %s doesn't have dependencies", $moduleName)); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) ->renderByFormat($output, $dependencies, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 416dcf34a..0f58c6ba2 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -4,7 +4,6 @@ use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Modules; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -50,8 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /* @var TableHelper $table */ - $table = $this->getHelper('table'); + $table = $this->getTableHelper(); $table ->setHeaders(['codePool', 'Name', 'Version', 'Status']) ->renderByFormat($output, iterator_to_array($modules), $input->getOption('format')); diff --git a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php index 62e974c17..2460b914c 100644 --- a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php @@ -5,7 +5,6 @@ use InvalidArgumentException; use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -75,8 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = [$eventName, implode("\n", $observerList)]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Event', 'Observers']) ->setRows($table) diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index 876d7605c..83a9ca791 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Developer\Module\Rewrite; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -52,8 +51,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (count($table) == 0) { $table = []; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Type', 'Class', 'Rewrite']) ->setRows($table) diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index a7e7679d4..cf70668d4 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -6,7 +6,6 @@ use Mage_Core_Model_Store; use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Command\AbstractMagentoStoreConfigCommand; -use N98\Util\Console\Helper\TableHelper; use Parameter; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -68,8 +67,7 @@ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true); $storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store)); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders([Parameter::class, 'Value']) ->renderByFormat($output, $storeInfoLines); diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index a6ea56bc8..3230d76ff 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -4,7 +4,6 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -44,8 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Theme']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index 6db5e28b4..5aed76463 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -6,7 +6,6 @@ use Mage; use Mage_Eav_Model_Entity_Type; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -84,8 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $headers[] = 'backend_type'; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders($headers) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index f9afc66e6..4496b5320 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -77,8 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = ['Frontend-Input-Renderer-Class', trim($attribute->getFrontend()->getInputRendererClass())]; } - $this - ->getHelper('table') + $tableHelper = $this->getTableHelper(); + $tableHelper ->setHeaders(['Type', 'Value']) ->renderByFormat($output, $table, $input->getOption('format')); return 0; diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index fe2bac7f8..58599e2bb 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Indexer; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -50,8 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table[] = [$index['code'], $index['status'], $index['last_runtime']]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['code', 'status', 'time']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index 8d1a69a82..87e005a2e 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -4,7 +4,6 @@ use Description; use Location; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -65,8 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('no script file found'); } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Script', Location::class, Description::class]) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/CheckCommand.php b/src/N98/Magento/Command/System/CheckCommand.php index 77e514da9..8f710e7b0 100644 --- a/src/N98/Magento/Command/System/CheckCommand.php +++ b/src/N98/Magento/Command/System/CheckCommand.php @@ -12,7 +12,6 @@ use N98\Magento\Command\System\Check\SimpleCheck; use N98\Magento\Command\System\Check\StoreCheck; use N98\Magento\Command\System\Check\WebsiteCheck; -use N98\Util\Console\Helper\TableHelper; use N98\Util\Unicode\Charset; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -157,8 +156,7 @@ protected function _printTable(InputInterface $input, OutputInterface $output, R $table[] = [$result->getResultGroup(), strip_tags($result->getMessage()), $result->getStatus()]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Group', 'Message', 'Result']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index b0234c1cb..3415eef1a 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -5,7 +5,6 @@ use Mage; use Mage_Cron_Model_Schedule; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -68,8 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($collection as $job) { $table[] = [$job->getJobCode(), $job->getStatus(), $job->getFinishedAt() ? $date->gmtDate(null, $date->timestamp($job->getFinishedAt()) + $offset) : '']; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Job', 'Status', 'Finished']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index bc4a29384..d92e0a9d8 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\System\Cron; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -45,8 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table = $this->getJobs(); - /** @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(array_keys(current($table))) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/InfoCommand.php b/src/N98/Magento/Command/System/InfoCommand.php index 1db3bc714..73dc9a284 100644 --- a/src/N98/Magento/Command/System/InfoCommand.php +++ b/src/N98/Magento/Command/System/InfoCommand.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -92,8 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $output->writeln((string) $this->infos[$settingArgument]); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['name', 'value']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php b/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php index 33fbc489e..c66f17d8f 100644 --- a/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php +++ b/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php @@ -7,7 +7,6 @@ use Mage; use N98\JUnitXml\Document as JUnitXmlDocument; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -139,8 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('log-junit')) { $this->logJUnit($table, $input->getOption('log-junit'), microtime($time) - $time); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders($headers) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Setup/RunCommand.php b/src/N98/Magento/Command/System/Setup/RunCommand.php index b07f9f345..6335fa155 100644 --- a/src/N98/Magento/Command/System/Setup/RunCommand.php +++ b/src/N98/Magento/Command/System/Setup/RunCommand.php @@ -6,7 +6,6 @@ use Mage; use Mage_Core_Model_Resource_Setup; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use ReflectionObject; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -103,8 +102,7 @@ protected function printStackTrace(OutputInterface $output, Exception $e) return $row; }); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $rows = []; $i = 1; foreach ($trace as $row) { @@ -122,8 +120,7 @@ protected function printStackTrace(OutputInterface $output, Exception $e) protected function printFile(OutputInterface $output, Exception $e) { if (preg_match('/Error\sin\sfile\:\s"(.+)\"\s-/', $e->getMessage(), $matches)) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $lines = \file($matches[1]); $rows = []; $i = 0; diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 5e9f71d47..4c92bbe85 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -4,7 +4,6 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -45,8 +44,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'code', 'unsecure_baseurl', 'secure_baseurl']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 4856ff5fb..14f5e507b 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -4,7 +4,6 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -46,8 +45,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'code']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 176b415d1..882f97c3c 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -4,7 +4,6 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -50,8 +49,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'code']) ->renderByFormat($output, $table, $input->getOption('format')); From 7f82409cf455ce8311fea7f46c4907d6fe071491 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 06:41:31 +0200 Subject: [PATCH 2/4] getQuestionHelper() --- .../Command/AbstractMagentoCommand.php | 9 +++---- .../Admin/User/ChangePasswordCommand.php | 4 +--- .../Command/Admin/User/CreateUserCommand.php | 3 +-- .../Command/Admin/User/DeleteUserCommand.php | 3 +-- .../Command/Category/Create/DummyCommand.php | 4 +--- .../Customer/ChangePasswordCommand.php | 4 +--- .../Command/Customer/CreateCommand.php | 4 +--- .../Magento/Command/Database/DropCommand.php | 4 +--- .../Magento/Command/Database/DumpCommand.php | 3 +-- .../Developer/Log/AbstractLogCommand.php | 5 +--- .../Developer/Module/UpdateCommand.php | 24 +++++++------------ .../Eav/Attribute/Create/DummyCommand.php | 4 +--- .../Command/Indexer/ReindexCommand.php | 5 +--- .../SubCommand/ChooseInstallationFolder.php | 2 +- .../Installer/SubCommand/DownloadMagento.php | 6 +---- .../Installer/SubCommand/InstallMagento.php | 4 +--- .../SubCommand/InstallSampleData.php | 2 +- .../SubCommand/SelectMagentoVersion.php | 2 +- .../Command/Installer/UninstallCommand.php | 4 +--- .../Command/LocalConfig/GenerateCommand.php | 4 +--- .../Command/Script/Repository/RunCommand.php | 4 +--- src/N98/Magento/Command/ScriptCommand.php | 4 +--- .../Command/SubCommand/AbstractSubCommand.php | 4 +--- .../Command/System/Cron/RunCommand.php | 5 +--- .../System/Setup/IncrementalCommand.php | 10 +++----- 25 files changed, 36 insertions(+), 91 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 8575442db..889e73e8a 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -555,8 +555,7 @@ protected function chooseInstallationFolder(InputInterface $input, OutputInterfa if (($installationFolder = $input->getOption('installationFolder')) == null) { $defaultFolder = './magento'; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $questionObj = new Question( 'Enter installation folder: [' . $defaultFolder . ']', $defaultFolder @@ -596,8 +595,7 @@ protected function getOrAskForArgument($argument, InputInterface $input, OutputI if ($inputArgument === null) { $message = $this->getArgumentMessage($argument, $message); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); return $dialog->ask($input, $output, new Question($message)); } @@ -621,8 +619,7 @@ protected function askForArrayEntry(array $entries, InputInterface $input, Outpu return $typeInput; }; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( "{$question}", $entries diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 62a618b60..0c606ed66 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -4,7 +4,6 @@ use Exception; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -40,8 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); // Username if (($username = $input->getArgument('username')) == null) { diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 9181fcc93..19f7950c1 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -42,8 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $username = $this->getOrAskForArgument('username', $input, $output); $email = $this->getOrAskForArgument('email', $input, $output); if (($password = $input->getArgument('password')) === null) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Password: '); $question->setHidden(true); $password = $dialog->ask($input, $output, $question); diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index d2dfd0633..584f4a4b7 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -43,8 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); // Username $id = $this->getOrAskForArgument('id', $input, $output, 'Username or Email'); diff --git a/src/N98/Magento/Command/Category/Create/DummyCommand.php b/src/N98/Magento/Command/Category/Create/DummyCommand.php index 27e4d5cfb..669fef306 100644 --- a/src/N98/Magento/Command/Category/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Category/Create/DummyCommand.php @@ -6,7 +6,6 @@ use Mage_Catalog_Model_Category; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -138,8 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ private function askForArguments($input, $output) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $_argument = []; // Store ID diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index 05e0878ff..d96fb3b0f 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -5,7 +5,6 @@ use Exception; use N98\Util\Console\Helper\ParameterHelper; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -54,8 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Password if (($password = $input->getArgument('password')) == null) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Password: '); $question->setHidden(true); $password = $dialog->ask($input, $output, $question); diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index 572e21d87..567130ac0 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Customer; use N98\Util\Console\Helper\ParameterHelper; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -42,8 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); // Password if (($password = $input->getArgument('password')) == null) { diff --git a/src/N98/Magento/Command/Database/DropCommand.php b/src/N98/Magento/Command/Database/DropCommand.php index 745e0173c..32b106ecd 100644 --- a/src/N98/Magento/Command/Database/DropCommand.php +++ b/src/N98/Magento/Command/Database/DropCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Database; use N98\Util\Console\Helper\DatabaseHelper; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -48,8 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectDbSettings($output); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); /** @var DatabaseHelper $dbHelper */ $dbHelper = $this->getHelper('database'); diff --git a/src/N98/Magento/Command/Database/DumpCommand.php b/src/N98/Magento/Command/Database/DumpCommand.php index b3df070c3..6f6bcb903 100644 --- a/src/N98/Magento/Command/Database/DumpCommand.php +++ b/src/N98/Magento/Command/Database/DumpCommand.php @@ -536,8 +536,7 @@ protected function getFileName(InputInterface $input, OutputInterface $output, C $defaultName = rtrim($fileName, '/') . '/' . $defaultName; } if (!$input->getOption('force')) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $fileName = $dialog->ask( $input, $output, diff --git a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php index 63f13dfc1..61ab9da1c 100644 --- a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php @@ -5,11 +5,9 @@ use InvalidArgumentException; use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; -use Symfony\Component\Console\Question\Question; use Symfony\Component\Finder\Finder; /** @@ -85,8 +83,7 @@ protected function askLogFile(InputInterface $input, OutputInterface $output) return ''; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $questionObj = new ChoiceQuestion('Please select a log file: ', $choices); $questionObj->setValidator(function ($typeInput) use ($files) { if (!isset($files[$typeInput - 1])) { diff --git a/src/N98/Magento/Command/Developer/Module/UpdateCommand.php b/src/N98/Magento/Command/Developer/Module/UpdateCommand.php index 10eac14f0..2e24740e8 100644 --- a/src/N98/Magento/Command/Developer/Module/UpdateCommand.php +++ b/src/N98/Magento/Command/Developer/Module/UpdateCommand.php @@ -258,8 +258,7 @@ protected function setVersion(InputInterface $input, OutputInterface $output, \S if ($this->shouldSetVersion($input)) { $modulesNode = $configXml->modules->{$this->getModuleNamespace()}; - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Enter version number: '); $version = trim($dialog->ask($input, $output, $question)); $modulesNode->version = $version; @@ -303,8 +302,7 @@ protected function setGlobalNode(InputInterface $input, OutputInterface $output, */ protected function addResourceModelNodeIfConfirmed(InputInterface $input, OutputInterface $output, \SimpleXMLElement $configXml) { - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ConfirmationQuestion( 'Would you like to also add a Resource Model(y/n)?', @@ -501,8 +499,7 @@ protected function askResourceModelOptions(InputInterface $input, OutputInterfac { $this->initResourceModelConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ConfirmationQuestion( 'Would you like to set mysql4 deprecated node(y/n)?', @@ -538,8 +535,7 @@ protected function askRoutersOptions(InputInterface $input, OutputInterface $out { $this->initRoutersConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', @@ -573,8 +569,7 @@ protected function askEventsOptions(InputInterface $input, OutputInterface $outp { $this->initEventsConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (global|frontend|adminhtml): ', @@ -616,8 +611,7 @@ protected function askLayoutUpdatesOptions(InputInterface $input, OutputInterfac { $this->initLayoutUpdatesConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', @@ -651,8 +645,7 @@ protected function askTranslateOptions(InputInterface $input, OutputInterface $o { $this->initTranslateConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', @@ -681,8 +674,7 @@ protected function askDefaultOptions(InputInterface $input, OutputInterface $out { $this->initDefaultConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Section Name (lowercase): '); $sectionName = strtolower(trim($dialog->ask($input, $output, $question))); diff --git a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php index 8777abef9..8f432c769 100644 --- a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php @@ -8,7 +8,6 @@ use Mage_Eav_Model_Entity_Attribute; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -107,8 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ private function askForArguments(InputInterface $input, OutputInterface $output) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $argument = []; // Attribute ID diff --git a/src/N98/Magento/Command/Indexer/ReindexCommand.php b/src/N98/Magento/Command/Indexer/ReindexCommand.php index fa319d165..a2227c887 100644 --- a/src/N98/Magento/Command/Indexer/ReindexCommand.php +++ b/src/N98/Magento/Command/Indexer/ReindexCommand.php @@ -5,12 +5,10 @@ use InvalidArgumentException; use Mage_Index_Model_Process; use N98\Util\BinaryString; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; -use Symfony\Component\Console\Question\Question; /** * Reindex command @@ -136,8 +134,7 @@ private function askForIndexCodes(InputInterface $input, OutputInterface $output return $returnCodes; }; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Please select a indexer: ', $choices diff --git a/src/N98/Magento/Command/Installer/SubCommand/ChooseInstallationFolder.php b/src/N98/Magento/Command/Installer/SubCommand/ChooseInstallationFolder.php index 34bb8a86a..88349d965 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/ChooseInstallationFolder.php +++ b/src/N98/Magento/Command/Installer/SubCommand/ChooseInstallationFolder.php @@ -55,7 +55,7 @@ public function execute() ); $question->setValidator($validateInstallationFolder); - $installationFolder = $this->getCommand()->getHelper('question')->ask( + $installationFolder = $this->getCommand()->getQuestionHelper()->ask( $this->input, $this->output, $question diff --git a/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php b/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php index 91b652976..960e4de96 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php +++ b/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php @@ -4,11 +4,9 @@ use Exception; use N98\Magento\Command\SubCommand\AbstractSubCommand; -use N98\Util\Console\Helper\ComposerHelper; use N98\Util\Exec; use N98\Util\ProcessArguments; use Symfony\Component\Console\Exception\RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Process\Process; @@ -43,9 +41,7 @@ private function implementation() $this->config->setArray('magentoPackage', $package); if (file_exists($this->config->getString('installationFolder') . '/app/etc/local.xml')) { - - /* @var QuestionHelper $dialog */ - $dialog = $this->command->getHelper('question'); + $dialog = $this->command->getQuestionHelper(); $skipInstallation = $dialog->ask( $this->input, $this->output, diff --git a/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php b/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php index 400a3eaef..8af55a023 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php +++ b/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php @@ -7,7 +7,6 @@ use N98\Util\Exec; use N98\Util\OperatingSystem; use Symfony\Component\Console\Exception\RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; @@ -46,8 +45,7 @@ public function execute() $this->getCommand()->getApplication()->setAutoExit(false); - /** @var $questionHelper QuestionHelper */ - $questionHelper = $this->getCommand()->getHelper('question'); + $questionHelper = $this->getCommand()->getQuestionHelper(); $defaults = $this->commandConfig['installation']['defaults']; diff --git a/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php b/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php index 5c748be2c..d13958677 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php +++ b/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php @@ -29,7 +29,7 @@ public function execute() return; } - $questionHelper = $this->command->getHelper('question'); + $questionHelper = $this->command->getQuestionHelper(); $installSampleData = ($this->input->getOption('installSampleData') !== null) ? StringTyped::parseBoolOption($this->input->getOption('installSampleData')) diff --git a/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php b/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php index 7a5f87aac..ebc036f5d 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php +++ b/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php @@ -45,7 +45,7 @@ public function execute() return $typeInput; }); - $type = $this->getCommand()->getHelper('question')->ask( + $type = $this->getCommand()->getQuestionHelper()->ask( $this->input, $this->output, $question diff --git a/src/N98/Magento/Command/Installer/UninstallCommand.php b/src/N98/Magento/Command/Installer/UninstallCommand.php index b71e7efc6..ceb458a59 100644 --- a/src/N98/Magento/Command/Installer/UninstallCommand.php +++ b/src/N98/Magento/Command/Installer/UninstallCommand.php @@ -5,7 +5,6 @@ use Exception; use N98\Magento\Command\AbstractMagentoCommand; use N98\Util\Filesystem; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\StringInput; @@ -60,8 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $this->getApplication()->setAutoExit(false); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $shouldUninstall = $input->getOption('force'); if (!$shouldUninstall) { diff --git a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php index cdb22388e..3a0c541b1 100644 --- a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php +++ b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php @@ -5,7 +5,6 @@ use DateTime; use InvalidArgumentException; use N98\Magento\Command\AbstractMagentoCommand; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -114,8 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function askForArguments(InputInterface $input, OutputInterface $output) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $messagePrefix = 'Please enter the '; $arguments = [ diff --git a/src/N98/Magento/Command/Script/Repository/RunCommand.php b/src/N98/Magento/Command/Script/Repository/RunCommand.php index bf6a045a5..2807973b7 100644 --- a/src/N98/Magento/Command/Script/Repository/RunCommand.php +++ b/src/N98/Magento/Command/Script/Repository/RunCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Script\Repository; use InvalidArgumentException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -77,8 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return $files[$typeInput]['fileinfo']->getPathname(); }; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Please select a script file: ', $choices diff --git a/src/N98/Magento/Command/ScriptCommand.php b/src/N98/Magento/Command/ScriptCommand.php index d437e3c7d..82822ca16 100644 --- a/src/N98/Magento/Command/ScriptCommand.php +++ b/src/N98/Magento/Command/ScriptCommand.php @@ -7,7 +7,6 @@ use N98\Util\BinaryString; use N98\Util\Exec; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -228,8 +227,7 @@ protected function registerVariable(InputInterface $input, OutputInterface $outp return $this->scriptVars[$matches[1]]; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); /** * Check for select "?[" diff --git a/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php b/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php index 1195da1db..5e6657a8c 100644 --- a/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php +++ b/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\SubCommand; use N98\Magento\Command\AbstractMagentoCommand; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; @@ -106,8 +105,7 @@ final protected function getOptionalBooleanOption($name, $question, $default = t return $flag; } else { - /** @var $questionHelper QuestionHelper */ - $questionHelper = $this->getCommand()->getHelper('question'); + $questionHelper = $this->getCommand()->getQuestionHelper(); $question = new Question( sprintf( diff --git a/src/N98/Magento/Command/System/Cron/RunCommand.php b/src/N98/Magento/Command/System/Cron/RunCommand.php index 6087d216f..0174d7ee6 100644 --- a/src/N98/Magento/Command/System/Cron/RunCommand.php +++ b/src/N98/Magento/Command/System/Cron/RunCommand.php @@ -7,13 +7,11 @@ use Mage_Core_Model_Config_Element; use Mage_Cron_Model_Schedule; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; 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\Question\ChoiceQuestion; -use Symfony\Component\Console\Question\Question; use Symfony\Component\Validator\Exception\InvalidArgumentException; /** @@ -104,8 +102,7 @@ protected function askJobCode(InputInterface $input, OutputInterface $output, ar $choices[] = '' . $job['Job'] . ''; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion('Please select job: ', $choices); $question->setValidator(function ($typeInput) use ($keyMap, $jobs) { $key = $keyMap[$typeInput]; diff --git a/src/N98/Magento/Command/System/Setup/IncrementalCommand.php b/src/N98/Magento/Command/System/Setup/IncrementalCommand.php index 07855d744..b0b3cd853 100644 --- a/src/N98/Magento/Command/System/Setup/IncrementalCommand.php +++ b/src/N98/Magento/Command/System/Setup/IncrementalCommand.php @@ -9,7 +9,6 @@ use N98\Magento\Command\AbstractMagentoCommand; use ReflectionClass; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -464,8 +463,7 @@ protected function _processExceptionDuringUpdate( $output->writeln(["Magento encountered an error while running the following setup resource.", "", " $name ", "", "The Good News: You know the error happened, and the database", "information below will help you fix this error!", "", "The Bad News: Because Magento/MySQL can't run setup resources", "transactionally your database is now in an half upgraded, invalid", "state. Even if you fix the error, new errors may occur due to", "this half upgraded, invalid state.", '', "What to Do: ", "1. Figure out why the error happened, and manually fix your", " database and/or system so it won't happen again.", "2. Restore your database from backup.", "3. Re-run the scripts.", "", "Exception Message:", $e->getMessage(), ""]); if ($magentoExceptionOutput) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to view raw Magento error text: '); $dialog->ask($input, $output, $question); @@ -504,8 +502,7 @@ protected function _runStructureOrDataScripts($toUpdate, array $needsUpdate, $ty $output = $this->_output; $output->writeln('The next ' . $type . ' update to run is ' . $toUpdate . ''); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to Run this update: '); $dialog->ask($input, $output, $question); @@ -590,8 +587,7 @@ protected function _listDetailedUpdateInformation(array $needsUpdate) $input = $this->_input; $output = $this->_output; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to View Update Information: '); $dialog->ask($input, $output, $question); From 344fdacef1baa59e1f2549737efc7d0560a8da21 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 06:58:15 +0200 Subject: [PATCH 3/4] getParameterHelper() --- src/N98/Magento/Command/Customer/ChangePasswordCommand.php | 4 +--- src/N98/Magento/Command/Customer/CreateCommand.php | 4 +--- src/N98/Magento/Command/Customer/CreateDummyCommand.php | 4 +--- src/N98/Magento/Command/Customer/DeleteCommand.php | 6 ++---- src/N98/Magento/Command/Customer/InfoCommand.php | 4 +--- src/N98/Magento/Command/Developer/Translate/SetCommand.php | 4 +--- src/N98/Magento/Command/OpenBrowserCommand.php | 4 +--- 7 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index d96fb3b0f..f52a21ee8 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Customer; use Exception; -use N98\Util\Console\Helper\ParameterHelper; use RuntimeException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -59,8 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $password = $dialog->ask($input, $output, $question); } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $email = $parameterHelper->askEmail($input, $output); $website = $parameterHelper->askWebsite($input, $output); diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index 567130ac0..cf41804a6 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Customer; -use N98\Util\Console\Helper\ParameterHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -60,8 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $lastname = $dialog->ask($input, $output, new Question('Lastname: ')); } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); // Email $email = $parameterHelper->askEmail($input, $output); diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index b2658fb11..f88253517 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -4,7 +4,6 @@ use Faker\Factory; use Locale; -use N98\Util\Console\Helper\ParameterHelper; use N98\Util\Faker\Provider\Internet; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -79,8 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $faker = Factory::create($input->getArgument('locale')); $faker->addProvider(new Internet($faker)); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $website = $parameterHelper->askWebsite($input, $output); diff --git a/src/N98/Magento/Command/Customer/DeleteCommand.php b/src/N98/Magento/Command/Customer/DeleteCommand.php index 6ccb5b6c2..c4946e317 100644 --- a/src/N98/Magento/Command/Customer/DeleteCommand.php +++ b/src/N98/Magento/Command/Customer/DeleteCommand.php @@ -6,7 +6,6 @@ use Mage_Customer_Model_Customer; use Mage_Customer_Model_Entity_Customer_Collection; use Mage_Customer_Model_Resource_Customer_Collection; -use N98\Util\Console\Helper\ParameterHelper; use RuntimeException; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; @@ -209,8 +208,7 @@ protected function getCustomer($id) /** @var \Mage_Customer_Model_Customer $customer */ $customer = $this->getCustomerModel()->load($id); if (!$customer->getId()) { - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $website = $parameterHelper->askWebsite($this->input, $this->output); $customer = $this->getCustomerModel() ->setWebsiteId($website->getId()) @@ -279,7 +277,7 @@ public function validateInt($answer) * @param string $message * @param string $default [optional] * - * @return \Symfony\Component\Console\Question\Question + * @return Question */ private function getQuestion($message, $default = null) { diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 5f103f80a..791ffe6c8 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -5,7 +5,6 @@ use Attribute; use Exception; use Mage_Customer_Model_Attribute; -use N98\Util\Console\Helper\ParameterHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -44,8 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $email = $parameterHelper->askEmail($input, $output); $website = $parameterHelper->askWebsite($input, $output); diff --git a/src/N98/Magento/Command/Developer/Translate/SetCommand.php b/src/N98/Magento/Command/Developer/Translate/SetCommand.php index 0a5c8b267..38e5a6a3e 100644 --- a/src/N98/Magento/Command/Developer/Translate/SetCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/SetCommand.php @@ -4,7 +4,6 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\ParameterHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\StringInput; @@ -43,8 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $store = $parameterHelper->askStore($input, $output); diff --git a/src/N98/Magento/Command/OpenBrowserCommand.php b/src/N98/Magento/Command/OpenBrowserCommand.php index f4e5fd27f..6626665ad 100644 --- a/src/N98/Magento/Command/OpenBrowserCommand.php +++ b/src/N98/Magento/Command/OpenBrowserCommand.php @@ -5,7 +5,6 @@ use Mage; use Mage_Core_Model_App; use Mage_Core_Model_Store; -use N98\Util\Console\Helper\ParameterHelper; use N98\Util\Exec; use N98\Util\OperatingSystem; use RuntimeException; @@ -49,8 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $store = $parameterHelper->askStore($input, $output, 'store', true); if ($store->getId() == Mage_Core_Model_App::ADMIN_STORE_ID) { From d8ce76f2bcafd76dae6490e964ab9bd917e4fe33 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 07:13:38 +0200 Subject: [PATCH 4/4] getDatabaseHelper() --- src/N98/Magento/Command/AbstractMagentoCommand.php | 9 +++++++++ .../Command/Database/AbstractDatabaseCommand.php | 11 +---------- .../Magento/Command/Database/AbstractShowCommand.php | 4 +--- src/N98/Magento/Command/Database/ConsoleCommand.php | 5 +---- src/N98/Magento/Command/Database/CreateCommand.php | 2 +- src/N98/Magento/Command/Database/DropCommand.php | 4 +--- src/N98/Magento/Command/Database/DumpCommand.php | 6 +----- src/N98/Magento/Command/Database/ImportCommand.php | 2 +- src/N98/Magento/Command/Database/InfoCommand.php | 4 +--- .../Command/Database/Maintain/CheckTablesCommand.php | 2 +- src/N98/Magento/Command/Database/QueryCommand.php | 3 +-- .../Command/Developer/Code/Model/MethodCommand.php | 4 +--- .../Command/Developer/Translate/ExportCommand.php | 4 +--- .../Installer/SubCommand/InstallSampleData.php | 5 +---- 14 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 889e73e8a..60ff7c702 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -14,6 +14,7 @@ use N98\Magento\Application; use N98\Magento\Command\SubCommand\ConfigBag; use N98\Magento\Command\SubCommand\SubCommandFactory; +use N98\Util\Console\Helper\DatabaseHelper; use N98\Util\Console\Helper\IoHelper; use N98\Util\Console\Helper\MagentoHelper; use N98\Util\Console\Helper\ParameterHelper; @@ -692,6 +693,14 @@ public function addFormatOption(): self return $this; } + /** + * @return DatabaseHelper + */ + public function getDatabaseHelper(): DatabaseHelper + { + return $this->getHelper('database'); + } + /** * @return IoHelper */ diff --git a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php index 0fb8cb190..411bf49d7 100644 --- a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php +++ b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php @@ -6,7 +6,6 @@ use N98\Magento\Command\Database\Compressor\AbstractCompressor; use N98\Magento\Command\Database\Compressor\Compressor; use N98\Magento\DbSettings; -use N98\Util\Console\Helper\DatabaseHelper; use Symfony\Component\Console\Output\OutputInterface; /** @@ -99,14 +98,6 @@ protected function _dsn() return $this->getDatabaseHelper()->dsn(); } - /** - * @return DatabaseHelper - */ - protected function getDatabaseHelper() - { - return $this->getHelper('database'); - } - /** * @param array $excludes * @param array $definitions @@ -118,6 +109,6 @@ protected function getDatabaseHelper() */ protected function resolveTables(array $excludes, array $definitions, array $resolved = []) { - return $this->getHelper('database')->resolveTables($excludes, $definitions, $resolved); + return $this->getDatabaseHelper()->resolveTables($excludes, $definitions, $resolved); } } diff --git a/src/N98/Magento/Command/Database/AbstractShowCommand.php b/src/N98/Magento/Command/Database/AbstractShowCommand.php index 23a54cc24..46a59a3bb 100644 --- a/src/N98/Magento/Command/Database/AbstractShowCommand.php +++ b/src/N98/Magento/Command/Database/AbstractShowCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Database; use Description; -use N98\Util\Console\Helper\DatabaseHelper; use N98\Util\Filesystem; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -173,8 +172,7 @@ protected function renderTable(array $header, array $rows) */ protected function initVariables($variable = null) { - /** @var DatabaseHelper $database */ - $database = $this->getHelper('database'); + $database = $this->getDatabaseHelper(); $this->_allVariables = $database->{$this->showMethod}($variable); } diff --git a/src/N98/Magento/Command/Database/ConsoleCommand.php b/src/N98/Magento/Command/Database/ConsoleCommand.php index 9da04fcbc..eaf940bf9 100644 --- a/src/N98/Magento/Command/Database/ConsoleCommand.php +++ b/src/N98/Magento/Command/Database/ConsoleCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Database; -use N98\Util\Console\Helper\DatabaseHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -79,9 +78,7 @@ private function processCommand($command) */ private function getMysqlClientToolConnection() { - /* @var DatabaseHelper $database */ - $database = $this->getHelper('database'); - + $database = $this->getDatabaseHelper(); return $database->getMysqlClientToolConnectionString(); } } diff --git a/src/N98/Magento/Command/Database/CreateCommand.php b/src/N98/Magento/Command/Database/CreateCommand.php index 75b089b32..d5fe0af1f 100644 --- a/src/N98/Magento/Command/Database/CreateCommand.php +++ b/src/N98/Magento/Command/Database/CreateCommand.php @@ -39,7 +39,7 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->getHelper('database')->createDatabase($output); + $this->getDatabaseHelper()->createDatabase($output); return 0; } } diff --git a/src/N98/Magento/Command/Database/DropCommand.php b/src/N98/Magento/Command/Database/DropCommand.php index 32b106ecd..d0f35dd9a 100644 --- a/src/N98/Magento/Command/Database/DropCommand.php +++ b/src/N98/Magento/Command/Database/DropCommand.php @@ -2,7 +2,6 @@ namespace N98\Magento\Command\Database; -use N98\Util\Console\Helper\DatabaseHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -48,8 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectDbSettings($output); $dialog = $this->getQuestionHelper(); - /** @var DatabaseHelper $dbHelper */ - $dbHelper = $this->getHelper('database'); + $dbHelper = $this->getDatabaseHelper(); if ($input->getOption('force')) { $shouldDrop = true; diff --git a/src/N98/Magento/Command/Database/DumpCommand.php b/src/N98/Magento/Command/Database/DumpCommand.php index 6f6bcb903..ea7c32ab6 100644 --- a/src/N98/Magento/Command/Database/DumpCommand.php +++ b/src/N98/Magento/Command/Database/DumpCommand.php @@ -5,10 +5,8 @@ use InvalidArgumentException; use N98\Magento\Command\Database\Compressor\Compressor; use N98\Util\Console\Enabler; -use N98\Util\Console\Helper\DatabaseHelper; use N98\Util\Exec; use N98\Util\VerifyOrDie; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -183,9 +181,7 @@ private function getTableDefinitions() $this->commandConfig = $this->getCommandConfig(); if (is_null($this->tableDefinitions)) { - /* @var DatabaseHelper $dbHelper */ - $dbHelper = $this->getHelper('database'); - + $dbHelper = $this->getDatabaseHelper(); $this->tableDefinitions = $dbHelper->getTableDefinitions($this->commandConfig); } diff --git a/src/N98/Magento/Command/Database/ImportCommand.php b/src/N98/Magento/Command/Database/ImportCommand.php index 8cbc1258f..d45ecfd7a 100644 --- a/src/N98/Magento/Command/Database/ImportCommand.php +++ b/src/N98/Magento/Command/Database/ImportCommand.php @@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectDbSettings($output); $this->writeSection($output, 'Import MySQL Database'); - $dbHelper = $this->getHelper('database'); + $dbHelper = $this->getDatabaseHelper(); $fileName = $this->checkFilename($input); diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index c0eb5ad10..c225e10f8 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -3,7 +3,6 @@ namespace N98\Magento\Command\Database; use InvalidArgumentException; -use N98\Util\Console\Helper\DatabaseHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -91,8 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $settings['JDBC-Connection-String'] = $jdbcConnectionString; - /* @var DatabaseHelper $database */ - $database = $this->getHelper('database'); + $database = $this->getDatabaseHelper(); $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); $settings['MySQL-Cli-String'] = $mysqlCliString; diff --git a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php index 9cbf4b498..9f9b90aa2 100644 --- a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php +++ b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->output = $output; $this->isTypeAllowed(); $this->detectMagento($output); - $this->dbHelper = $this->getHelper('database'); + $this->dbHelper = $this->getDatabaseHelper(); $this->showProgress = $input->getOption('format') == null; if ($input->getOption('table')) { diff --git a/src/N98/Magento/Command/Database/QueryCommand.php b/src/N98/Magento/Command/Database/QueryCommand.php index a336bc42b..5af63a4ad 100644 --- a/src/N98/Magento/Command/Database/QueryCommand.php +++ b/src/N98/Magento/Command/Database/QueryCommand.php @@ -77,8 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $query = $this->getOrAskForArgument('query', $input, $output, 'SQL Query'); - /** @var \N98\Util\Console\Helper\DatabaseHelper $helper */ - $helper = $this->getHelper('database'); + $helper = $this->getDatabaseHelper(); $exec = sprintf('mysql %s -e %s', $helper->getMysqlClientToolConnectionString(), escapeshellarg($query)); if ($input->getOption('only-command')) { diff --git a/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php b/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php index 0e264b3d4..dc8d37a8b 100644 --- a/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php +++ b/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php @@ -164,9 +164,7 @@ protected function getColumnType($columnType) */ protected function initTableColumns() { - $dbHelper = $this->getHelper('database'); - /* @var \N98\Util\Console\Helper\DatabaseHelper $dbHelper */ - /** @var PDO $connection */ + $dbHelper = $this->getDatabaseHelper(); $connection = $dbHelper->getConnection($this->_output); $stmt = $connection->query('SHOW COLUMNS FROM ' . $this->_mageModelTable, PDO::FETCH_ASSOC); foreach ($stmt as $row) { diff --git a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php index b7e7f1b2e..ae2a7bfe2 100644 --- a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php @@ -5,7 +5,6 @@ use Locale; use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\DatabaseHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -41,8 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - /** @var DatabaseHelper $helper */ - $helper = $this->getHelper('database'); + $helper = $this->getDatabaseHelper(); $db = $helper->getConnection(); $filename = $input->getArgument('filename'); diff --git a/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php b/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php index d13958677..c231998fb 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php +++ b/src/N98/Magento/Command/Installer/SubCommand/InstallSampleData.php @@ -3,11 +3,9 @@ namespace N98\Magento\Command\Installer\SubCommand; use N98\Magento\Command\SubCommand\AbstractSubCommand; -use N98\Util\Console\Helper\DatabaseHelper; use N98\Util\Database; use N98\Util\Exec; use N98\Util\Filesystem; -use N98\Util\OperatingSystem; use N98\Util\StringTyped; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Process\Process; @@ -119,8 +117,7 @@ private function installSampleData(array $demoPackageData): void $this->config['installationFolder'] . '/magento_*sample_data*sql' ); - /** @var DatabaseHelper $dbHelper */ - $dbHelper = $this->command->getHelper('database'); + $dbHelper = $this->command->getDatabaseHelper(); if (isset($sampleDataSqlFile[0])) { $this->output->writeln('Import sample data db data');