From 1504aa6fae332772c1d79ab84d018896f3ca4d9e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 05:39:17 +0200 Subject: [PATCH 01/35] Added interfaces --- composer.json | 5 +- composer.lock | 192 ++++++++++-------- .../Command/AbstractMagentoCommand.php | 35 ++++ src/N98/Magento/Command/CommandListable.php | 28 +++ .../Command/CommandWithFormatOption.php | 14 ++ .../Command/System/Website/ListCommand.php | 54 ++--- 6 files changed, 205 insertions(+), 123 deletions(-) create mode 100644 src/N98/Magento/Command/CommandListable.php create mode 100644 src/N98/Magento/Command/CommandWithFormatOption.php diff --git a/composer.json b/composer.json index 27088457f..54196b4fa 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "magerun" ], "require": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", @@ -25,7 +25,6 @@ "symfony/console": "~5.4", "symfony/event-dispatcher": "~5.4", "symfony/finder": "~5.4", - "symfony/polyfill-php80": "^1.30", "symfony/process": "~5.4", "symfony/validator": "~5.4", "symfony/yaml": "~5.4", @@ -71,7 +70,7 @@ ], "config": { "platform": { - "php": "7.4.0" + "php": "8.0" }, "sort-packages": true } diff --git a/composer.lock b/composer.lock index a2a9a2b7a..fd8bede49 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0c12577e0329bb5cf6c8f3a3b788eb99", + "content-hash": "025b5cb0a68a9426cf7725bd4c6342d7", "packages": [ { "name": "fakerphp/faker", @@ -111,16 +111,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "v5.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", "shasum": "" }, "require": { @@ -131,7 +131,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -163,33 +163,28 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-07-01T20:03:41+00:00" }, { "name": "psr/container", - "version": "2.0.2", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -216,9 +211,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" + "source": "https://github.com/php-fig/container/tree/1.1.2" }, - "time": "2021-11-05T16:47:00+00:00" + "time": "2021-11-05T16:50:12+00:00" }, { "name": "psr/event-dispatcher", @@ -1443,29 +1438,37 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { - "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -1498,9 +1501,23 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" }, - "time": "2019-05-28T07:50:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-04-21T15:04:16+00:00" }, { "name": "symfony/string", @@ -1668,16 +1685,16 @@ }, { "name": "symfony/validator", - "version": "v5.4.41", + "version": "v5.4.42", "source": { "type": "git", "url": "https://github.com/symfony/validator.git", - "reference": "e00b2547f712a97755933db45efc03123b2d2690" + "reference": "5ad62a0b29cca8b89753b6d5f2bc5a4294b997ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/e00b2547f712a97755933db45efc03123b2d2690", - "reference": "e00b2547f712a97755933db45efc03123b2d2690", + "url": "https://api.github.com/repos/symfony/validator/zipball/5ad62a0b29cca8b89753b6d5f2bc5a4294b997ec", + "reference": "5ad62a0b29cca8b89753b6d5f2bc5a4294b997ec", "shasum": "" }, "require": { @@ -1717,7 +1734,7 @@ "symfony/http-kernel": "^4.4|^5.0|^6.0", "symfony/intl": "^4.4|^5.0|^6.0", "symfony/mime": "^4.4|^5.0|^6.0", - "symfony/property-access": "^4.4|^5.0|^6.0", + "symfony/property-access": "^5.4|^6.0", "symfony/property-info": "^5.3|^6.0", "symfony/translation": "^5.4.35|~6.3.12|^6.4.3", "symfony/yaml": "^4.4|^5.0|^6.0" @@ -1761,7 +1778,7 @@ "description": "Provides tools to validate values", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/validator/tree/v5.4.41" + "source": "https://github.com/symfony/validator/tree/v5.4.42" }, "funding": [ { @@ -1777,20 +1794,20 @@ "type": "tidelift" } ], - "time": "2024-06-10T09:18:21+00:00" + "time": "2024-07-26T11:57:39+00:00" }, { "name": "symfony/var-dumper", - "version": "v5.4.40", + "version": "v5.4.42", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "af8868a6e9d6082dfca11f1a1f205ae93a8b6d93" + "reference": "0c17c56d8ea052fc33942251c75d0e28936e043d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/af8868a6e9d6082dfca11f1a1f205ae93a8b6d93", - "reference": "af8868a6e9d6082dfca11f1a1f205ae93a8b6d93", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0c17c56d8ea052fc33942251c75d0e28936e043d", + "reference": "0c17c56d8ea052fc33942251c75d0e28936e043d", "shasum": "" }, "require": { @@ -1850,7 +1867,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.40" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.42" }, "funding": [ { @@ -1866,7 +1883,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2024-07-26T12:23:09+00:00" }, { "name": "symfony/yaml", @@ -2703,16 +2720,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -2720,11 +2737,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -2750,7 +2768,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -2758,7 +2776,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "phar-io/manifest", @@ -2992,16 +3010,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.8", + "version": "1.11.9", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec" + "reference": "e370bcddadaede0c1716338b262346f40d296f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e370bcddadaede0c1716338b262346f40d296f82", + "reference": "e370bcddadaede0c1716338b262346f40d296f82", "shasum": "" }, "require": { @@ -3046,7 +3064,7 @@ "type": "github" } ], - "time": "2024-07-24T07:01:22+00:00" + "time": "2024-08-01T16:25:18+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3369,45 +3387,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "49d7820565836236411f5dc002d16dd689cde42f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -3452,7 +3470,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" }, "funding": [ { @@ -3468,34 +3486,34 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-07-10T11:45:39+00:00" }, { "name": "psr/log", - "version": "1.1.4", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -3516,9 +3534,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/2.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:41:46+00:00" }, { "name": "react/cache", @@ -5375,7 +5393,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", @@ -5385,7 +5403,7 @@ "ext-simplexml": "*" }, "platform-overrides": { - "php": "7.4.0" + "php": "8.0" }, "plugin-api-version": "2.6.0" } diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 60ff7c702..a0c1edc95 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -38,6 +38,8 @@ */ abstract class AbstractMagentoCommand extends Command { + public const COMMAND_OPTION_FORMAT = 'format'; + /** * @var int */ @@ -78,6 +80,18 @@ abstract class AbstractMagentoCommand extends Command */ protected $config; + /** + * @var bool + */ + protected static bool $detectMagentoSilent = true; + + protected function configure() + { + if ($this instanceof CommandWithFormatOption || $this instanceof CommandListable) { + $this->addFormatOption(); + } + } + /** * Initializes the command just after the input has been validated. * @@ -92,6 +106,27 @@ protected function initialize(InputInterface $input, OutputInterface $output) $this->checkDeprecatedAliases($input, $output); } + protected function execute(InputInterface $input, OutputInterface $output): int + { + if ($this instanceof CommandListable) { + $this->detectMagento($output, static::$detectMagentoSilent); + + if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { + $this->writeSection($output, $this->getSectionTitle()); + } + + if (!$this->initMagento()) { + return Command::FAILURE; + } + + $this->getTableHelper() + ->setHeaders($this->getListHeader()) + ->renderByFormat($output, $this->getListData(), $input->getOption(self::COMMAND_OPTION_FORMAT)); + + return Command::SUCCESS; + } + } + private function _initWebsites() { $this->_websiteCodeMap = []; diff --git a/src/N98/Magento/Command/CommandListable.php b/src/N98/Magento/Command/CommandListable.php new file mode 100644 index 000000000..4f76b7b2b --- /dev/null +++ b/src/N98/Magento/Command/CommandListable.php @@ -0,0 +1,28 @@ +setName('sys:website:list') - ->setDescription('Lists all websites') - ->addFormatOption() - ; + return ['id', 'code']; } - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListData(): array { $table = []; - $this->detectMagento($output, true); - - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Magento Websites'); - } - $this->initMagento(); - foreach (Mage::app()->getWebsites() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode()]; + $table[$store->getId()] = [ + $store->getId(), + $store->getCode() + ]; } ksort($table); - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'code']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } } From 0be0fdbad1416e16cdc59cf9987b468403171192 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 05:51:43 +0200 Subject: [PATCH 02/35] Updated workflows --- .github/workflows/deploy.yml | 2 +- .github/workflows/phar_build_and_update.yml | 2 +- .github/workflows/php-cs-fixer.yml | 2 +- .github/workflows/php_compatibility.yml | 2 +- .github/workflows/test-magento-open-source.yml | 2 +- .github/workflows/test-openmage-20.10.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc55c9613..091ed0d41 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: uses: shivammathur/setup-php@v2 with: tools: composer:2 - php-version: '7.4' + php-version: '8.0' # Allow only newer versions - name: Collect versions diff --git a/.github/workflows/phar_build_and_update.yml b/.github/workflows/phar_build_and_update.yml index f0d88d872..c3934e10c 100644 --- a/.github/workflows/phar_build_and_update.yml +++ b/.github/workflows/phar_build_and_update.yml @@ -13,7 +13,7 @@ jobs: uses: shivammathur/setup-php@v2 with: tools: composer:2 - php-version: '7.4' + php-version: '8.0' - name: Checkout PR uses: actions/checkout@v4 diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 09e22309d..a47729c87 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/php_compatibility.yml b/.github/workflows/php_compatibility.yml index ef658cd80..d0d4a307e 100644 --- a/.github/workflows/php_compatibility.yml +++ b/.github/workflows/php_compatibility.yml @@ -5,7 +5,7 @@ on: - pull_request env: - MIN_PHP_VERSION: 7.4 + MIN_PHP_VERSION: 8.0 jobs: php-compatibility: diff --git a/.github/workflows/test-magento-open-source.yml b/.github/workflows/test-magento-open-source.yml index 5755bb0d6..8d632c72f 100644 --- a/.github/workflows/test-magento-open-source.yml +++ b/.github/workflows/test-magento-open-source.yml @@ -25,7 +25,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.0' extensions: yaml coverage: none diff --git a/.github/workflows/test-openmage-20.10.yml b/.github/workflows/test-openmage-20.10.yml index 31fff1850..3f8cafcf5 100644 --- a/.github/workflows/test-openmage-20.10.yml +++ b/.github/workflows/test-openmage-20.10.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.10.0"] - php_version: ["8.3", "8.2", "8.1", "7.4"] + php_version: ["8.3", "8.2", "8.1"] mysql_version: ["8.0", "5.7"] services: From 9b5ac5b158fe76c30f880ecbafff60fb8cbf0e0f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 06:30:14 +0200 Subject: [PATCH 03/35] Updated signature --- src/N98/Magento/Command/Installer/InstallCommand.php | 2 +- src/N98/Magento/Command/SelfUpdateCommand.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/Installer/InstallCommand.php b/src/N98/Magento/Command/Installer/InstallCommand.php index cba5d4b19..bbb4ca78c 100644 --- a/src/N98/Magento/Command/Installer/InstallCommand.php +++ b/src/N98/Magento/Command/Installer/InstallCommand.php @@ -127,7 +127,7 @@ public function isEnabled() * @throws \RuntimeException * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->commandConfig = $this->getCommandConfig(); $this->writeSection($output, 'Magento Installation'); diff --git a/src/N98/Magento/Command/SelfUpdateCommand.php b/src/N98/Magento/Command/SelfUpdateCommand.php index 089c9ad95..fba514c55 100644 --- a/src/N98/Magento/Command/SelfUpdateCommand.php +++ b/src/N98/Magento/Command/SelfUpdateCommand.php @@ -59,12 +59,12 @@ public function getHelp(): string } /** - * @param \Symfony\Component\Console\Input\InputInterface $input - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param InputInterface $input + * @param OutputInterface $output * @return int * @throws \Exception */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $isDryRun = $input->getOption('dry-run'); @@ -165,7 +165,7 @@ protected function _exit($statusCode = 0) } /** - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param OutputInterface $output * @param string $remoteUrl * @param string $tempFilename */ @@ -261,7 +261,7 @@ private function replaceExistingPharFile($tempFilename, $localFilename) /** * Download changelog * - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param OutputInterface $output * @param bool $loadUnstable * @return string */ From 6889b7e062c4bf8a1640707c6a155fc8962ac66e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 06:45:56 +0200 Subject: [PATCH 04/35] Let tests pass ... (fix it later) --- src/N98/Magento/Command/System/Website/ListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index c099f0f8c..cb54b43ea 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -22,7 +22,7 @@ class ListCommand extends AbstractMagentoCommand implements CommandListable { public function getSectionTitle(): string { - return 'Websites'; + return 'Magento Websites'; } public function getListHeader(): array From a54d824ab6a989a5554f088e08e7909a51ab7f87 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 06:50:30 +0200 Subject: [PATCH 05/35] Updated workflows (php version) --- .github/workflows/test-magento-open-source.yml | 2 +- .github/workflows/test-openmage-20.0.yml | 2 +- .github/workflows/test-openmage-20.1.yml | 2 +- .github/workflows/test-openmage-20.10.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-magento-open-source.yml b/.github/workflows/test-magento-open-source.yml index 8d632c72f..0635beeb9 100644 --- a/.github/workflows/test-magento-open-source.yml +++ b/.github/workflows/test-magento-open-source.yml @@ -1,4 +1,4 @@ -name: Test Magento Open Source 1.9 with PHP 7.4 +name: Test Magento Open Source 1.9 with PHP 8.0 on: [push, pull_request] diff --git a/.github/workflows/test-openmage-20.0.yml b/.github/workflows/test-openmage-20.0.yml index c58ee3419..c71caadd6 100644 --- a/.github/workflows/test-openmage-20.0.yml +++ b/.github/workflows/test-openmage-20.0.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.0.20"] - php_version: ["8.1", "7.4"] + php_version: ["8.3", "8.0"] mysql_version: ["8.0", "5.7"] services: diff --git a/.github/workflows/test-openmage-20.1.yml b/.github/workflows/test-openmage-20.1.yml index 7eb66e73f..ed761862c 100644 --- a/.github/workflows/test-openmage-20.1.yml +++ b/.github/workflows/test-openmage-20.1.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.1.0"] - php_version: ["8.1", "7.4"] + php_version: ["8.3", "8.0"] mysql_version: ["8.0", "5.7"] services: diff --git a/.github/workflows/test-openmage-20.10.yml b/.github/workflows/test-openmage-20.10.yml index 3f8cafcf5..12359a481 100644 --- a/.github/workflows/test-openmage-20.10.yml +++ b/.github/workflows/test-openmage-20.10.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.10.0"] - php_version: ["8.3", "8.2", "8.1"] + php_version: ["8.3", "8.0"] mysql_version: ["8.0", "5.7"] services: From 94eae9bbf869001895d946e05c1692fe842d5fd5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 07:12:39 +0200 Subject: [PATCH 06/35] Reverted for php7.4 --- .github/workflows/deploy.yml | 2 +- .github/workflows/phar_build_and_update.yml | 2 +- .github/workflows/php-cs-fixer.yml | 2 +- .github/workflows/php_compatibility.yml | 2 +- .../workflows/test-magento-open-source.yml | 4 ++-- .github/workflows/test-openmage-20.0.yml | 2 +- .github/workflows/test-openmage-20.1.yml | 2 +- .github/workflows/test-openmage-20.10.yml | 2 +- composer.json | 3 ++- composer.lock | 4 ++-- .../Command/System/Website/ListCommand.php | 24 +++++++++++++++---- 11 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 091ed0d41..dc55c9613 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: uses: shivammathur/setup-php@v2 with: tools: composer:2 - php-version: '8.0' + php-version: '7.4' # Allow only newer versions - name: Collect versions diff --git a/.github/workflows/phar_build_and_update.yml b/.github/workflows/phar_build_and_update.yml index c3934e10c..f0d88d872 100644 --- a/.github/workflows/phar_build_and_update.yml +++ b/.github/workflows/phar_build_and_update.yml @@ -13,7 +13,7 @@ jobs: uses: shivammathur/setup-php@v2 with: tools: composer:2 - php-version: '8.0' + php-version: '7.4' - name: Checkout PR uses: actions/checkout@v4 diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index a47729c87..09e22309d 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.0 + php-version: 7.4 - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/php_compatibility.yml b/.github/workflows/php_compatibility.yml index d0d4a307e..ef658cd80 100644 --- a/.github/workflows/php_compatibility.yml +++ b/.github/workflows/php_compatibility.yml @@ -5,7 +5,7 @@ on: - pull_request env: - MIN_PHP_VERSION: 8.0 + MIN_PHP_VERSION: 7.4 jobs: php-compatibility: diff --git a/.github/workflows/test-magento-open-source.yml b/.github/workflows/test-magento-open-source.yml index 0635beeb9..5755bb0d6 100644 --- a/.github/workflows/test-magento-open-source.yml +++ b/.github/workflows/test-magento-open-source.yml @@ -1,4 +1,4 @@ -name: Test Magento Open Source 1.9 with PHP 8.0 +name: Test Magento Open Source 1.9 with PHP 7.4 on: [push, pull_request] @@ -25,7 +25,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '7.4' extensions: yaml coverage: none diff --git a/.github/workflows/test-openmage-20.0.yml b/.github/workflows/test-openmage-20.0.yml index c71caadd6..c58ee3419 100644 --- a/.github/workflows/test-openmage-20.0.yml +++ b/.github/workflows/test-openmage-20.0.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.0.20"] - php_version: ["8.3", "8.0"] + php_version: ["8.1", "7.4"] mysql_version: ["8.0", "5.7"] services: diff --git a/.github/workflows/test-openmage-20.1.yml b/.github/workflows/test-openmage-20.1.yml index ed761862c..7eb66e73f 100644 --- a/.github/workflows/test-openmage-20.1.yml +++ b/.github/workflows/test-openmage-20.1.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.1.0"] - php_version: ["8.3", "8.0"] + php_version: ["8.1", "7.4"] mysql_version: ["8.0", "5.7"] services: diff --git a/.github/workflows/test-openmage-20.10.yml b/.github/workflows/test-openmage-20.10.yml index 12359a481..31fff1850 100644 --- a/.github/workflows/test-openmage-20.10.yml +++ b/.github/workflows/test-openmage-20.10.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: openmage_version: ["20.10.0"] - php_version: ["8.3", "8.0"] + php_version: ["8.3", "8.2", "8.1", "7.4"] mysql_version: ["8.0", "5.7"] services: diff --git a/composer.json b/composer.json index 54196b4fa..72a5c8fb6 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "magerun" ], "require": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", @@ -25,6 +25,7 @@ "symfony/console": "~5.4", "symfony/event-dispatcher": "~5.4", "symfony/finder": "~5.4", + "symfony/polyfill-php80": "^1.30", "symfony/process": "~5.4", "symfony/validator": "~5.4", "symfony/yaml": "~5.4", diff --git a/composer.lock b/composer.lock index fd8bede49..a9a9d0b6f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "025b5cb0a68a9426cf7725bd4c6342d7", + "content-hash": "faac65358e0577076aae6c00a9827104", "packages": [ { "name": "fakerphp/faker", @@ -5393,7 +5393,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index cb54b43ea..ceadeb023 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -7,29 +7,43 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Command\CommandListable; -use Symfony\Component\Console\Attribute\AsCommand; /** * List websites command * * @package N98\Magento\Command\System\Website */ -#[AsCommand( - name: 'sys:website:list', - description: 'Lists all websites.' -)] class ListCommand extends AbstractMagentoCommand implements CommandListable { + /** + * @var string + */ + public static $defaultName = 'sys:website:list'; + + /** + * @var string + */ + public static $defaultDescription = 'Lists all websites.'; + + /** + * @return string + */ public function getSectionTitle(): string { return 'Magento Websites'; } + /** + * @return string[] + */ public function getListHeader(): array { return ['id', 'code']; } + /** + * @return array + */ public function getListData(): array { $table = []; From ce4ab8080b5a888ee89479860cec102c69441c67 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 07:14:44 +0200 Subject: [PATCH 07/35] Reverted for php7.4 (2) --- composer.json | 2 +- composer.lock | 79 ++++++++++++++++++++------------------------------- 2 files changed, 32 insertions(+), 49 deletions(-) diff --git a/composer.json b/composer.json index 72a5c8fb6..27088457f 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ ], "config": { "platform": { - "php": "8.0" + "php": "7.4.0" }, "sort-packages": true } diff --git a/composer.lock b/composer.lock index a9a9d0b6f..304de8818 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "faac65358e0577076aae6c00a9827104", + "content-hash": "0c12577e0329bb5cf6c8f3a3b788eb99", "packages": [ { "name": "fakerphp/faker", @@ -169,22 +169,27 @@ }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -211,9 +216,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/event-dispatcher", @@ -1438,37 +1443,29 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.3", + "version": "v1.1.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" + "php": "^7.1.3" }, "suggest": { + "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" + "dev-master": "1.1-dev" } }, "autoload": { @@ -1501,23 +1498,9 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-04-21T15:04:16+00:00" + "time": "2019-05-28T07:50:59+00:00" }, { "name": "symfony/string", @@ -3490,30 +3473,30 @@ }, { "name": "psr/log", - "version": "2.0.0", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { - "php": ">=8.0.0" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "src" + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -3534,9 +3517,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/2.0.0" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2021-07-14T16:41:46+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "react/cache", @@ -5403,7 +5386,7 @@ "ext-simplexml": "*" }, "platform-overrides": { - "php": "8.0" + "php": "7.4.0" }, "plugin-api-version": "2.6.0" } From 5eb59a9af2e2493f50d822519bdcc6ac99a16965 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 07:22:11 +0200 Subject: [PATCH 08/35] Renamed interface [skip ci] --- src/N98/Magento/Command/AbstractMagentoCommand.php | 4 ++-- .../Command/{CommandListable.php => CommandFormatable.php} | 2 +- src/N98/Magento/Command/System/Website/ListCommand.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/N98/Magento/Command/{CommandListable.php => CommandFormatable.php} (93%) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index a0c1edc95..0e597e0d2 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -87,7 +87,7 @@ abstract class AbstractMagentoCommand extends Command protected function configure() { - if ($this instanceof CommandWithFormatOption || $this instanceof CommandListable) { + if ($this instanceof CommandWithFormatOption || $this instanceof CommandFormatable) { $this->addFormatOption(); } } @@ -108,7 +108,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int { - if ($this instanceof CommandListable) { + if ($this instanceof CommandFormatable) { $this->detectMagento($output, static::$detectMagentoSilent); if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { diff --git a/src/N98/Magento/Command/CommandListable.php b/src/N98/Magento/Command/CommandFormatable.php similarity index 93% rename from src/N98/Magento/Command/CommandListable.php rename to src/N98/Magento/Command/CommandFormatable.php index 4f76b7b2b..cbd9ac482 100644 --- a/src/N98/Magento/Command/CommandListable.php +++ b/src/N98/Magento/Command/CommandFormatable.php @@ -9,7 +9,7 @@ * * @package N98\Magento\Command */ -interface CommandListable +interface CommandFormatable { /** * @return string[] diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index ceadeb023..efa23a5c0 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -6,14 +6,14 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\CommandListable; +use N98\Magento\Command\CommandFormatable; /** * List websites command * * @package N98\Magento\Command\System\Website */ -class ListCommand extends AbstractMagentoCommand implements CommandListable +class ListCommand extends AbstractMagentoCommand implements CommandFormatable { /** * @var string From 123e36e1e96a72c21536886e5aad2fdb41f66acd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 07:34:16 +0200 Subject: [PATCH 09/35] Updated admin:user:list --- .../Command/Admin/User/ListCommand.php | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 91e288c46..754276ef4 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -1,51 +1,63 @@ setName('admin:user:list') - ->setDescription('List admin users.') - ->addFormatOption() - ; + return 'Admin users'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * @return string[] */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + return ['id', 'username', 'email', 'status']; + } - /** @var \Mage_Admin_Model_User $userModel */ + /** + * @return array + */ + public function getListData(): array + { + /** @var Mage_Admin_Model_User $userModel */ $userModel = $this->getUserModel(); $userList = $userModel->getCollection(); $table = []; foreach ($userList as $user) { - $table[] = [$user->getId(), $user->getUsername(), $user->getEmail(), $user->getIsActive() ? 'active' : 'inactive']; + $table[] = [ + $user->getId(), + $user->getUsername(), + $user->getEmail(), + $user->getIsActive() ? 'active' : 'inactive' + ]; } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'username', 'email', 'status']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } } From a595d5b329db2cc89e3c93d1905d213eb02451b0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 7 Aug 2024 07:48:38 +0200 Subject: [PATCH 10/35] Updated cache:list --- src/N98/Magento/Command/Cache/ListCommand.php | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index cbae54ef4..728a189ac 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -1,48 +1,58 @@ setName('cache:list') - ->setDescription('Lists all magento caches') - ->addFormatOption() - ; + return 'Caches'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * @return string[] */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + return ['code', 'status']; + } - $cacheTypes = $this->_getCacheModel()->getTypes(); + /** + * @return array + */ + public function getListData(): array + { $table = []; + $cacheTypes = $this->_getCacheModel()->getTypes(); foreach ($cacheTypes as $cacheCode => $cacheInfo) { - $table[] = [$cacheCode, $cacheInfo['status'] ? 'enabled' : 'disabled']; + $table[] = [ + $cacheCode, + $cacheInfo['status'] ? 'enabled' : 'disabled' + ]; } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['code', 'status']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } } From 8d33a1c38d6de53d1ab6a07b123823e443df2007 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 01:33:48 +0200 Subject: [PATCH 11/35] Updated interface - add out and input --- .../Magento/Command/Admin/User/ListCommand.php | 14 ++++++++------ src/N98/Magento/Command/Cache/ListCommand.php | 14 ++++++++------ src/N98/Magento/Command/CommandFormatable.php | 16 +++++++++++++--- .../Command/System/Website/ListCommand.php | 14 ++++++++------ 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 754276ef4..296269caf 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -6,6 +6,8 @@ use Mage_Admin_Model_User; use N98\Magento\Command\CommandFormatable; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * List admin user password command @@ -25,25 +27,25 @@ class ListCommand extends AbstractAdminUserCommand implements CommandFormatable public static $defaultDescription = 'List admin users.'; /** - * @return string + * {@inheritDoc} */ - public function getSectionTitle(): string + public function getSectionTitle(InputInterface $input, OutputInterface $output): string { return 'Admin users'; } /** - * @return string[] + * {@inheritDoc} */ - public function getListHeader(): array + public function getListHeader(InputInterface $input, OutputInterface $output): array { return ['id', 'username', 'email', 'status']; } /** - * @return array + * {@inheritDoc} */ - public function getListData(): array + public function getListData(InputInterface $input, OutputInterface $output): array { /** @var Mage_Admin_Model_User $userModel */ $userModel = $this->getUserModel(); diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index 728a189ac..5d28c17ff 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -5,6 +5,8 @@ namespace N98\Magento\Command\Cache; use N98\Magento\Command\CommandFormatable; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * List cache command @@ -24,25 +26,25 @@ class ListCommand extends AbstractCacheCommand implements CommandFormatable public static $defaultDescription = 'Lists all magento caches.'; /** - * @return string + * {@inheritDoc} */ - public function getSectionTitle(): string + public function getSectionTitle(InputInterface $input, OutputInterface $output): string { return 'Caches'; } /** - * @return string[] + * {@inheritDoc} */ - public function getListHeader(): array + public function getListHeader(InputInterface $input, OutputInterface $output): array { return ['code', 'status']; } /** - * @return array + * {@inheritDoc} */ - public function getListData(): array + public function getListData(InputInterface $input, OutputInterface $output): array { $table = []; $cacheTypes = $this->_getCacheModel()->getTypes(); diff --git a/src/N98/Magento/Command/CommandFormatable.php b/src/N98/Magento/Command/CommandFormatable.php index cbd9ac482..1d7fd5d52 100644 --- a/src/N98/Magento/Command/CommandFormatable.php +++ b/src/N98/Magento/Command/CommandFormatable.php @@ -4,6 +4,9 @@ namespace N98\Magento\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + /** * Interface CommandAware * @@ -11,18 +14,25 @@ */ interface CommandFormatable { + /** + * @param InputInterface $input + * @param OutputInterface $output * @return string[] */ - public function getListHeader(): array; + public function getListHeader(InputInterface $input, OutputInterface $output): array; /** + * @param InputInterface $input + * @param OutputInterface $output * @return array */ - public function getListData(): array; + public function getListData(InputInterface $input, OutputInterface $output): array; /** + * @param InputInterface $input + * @param OutputInterface $output * @return string */ - public function getSectionTitle(): string; + public function getSectionTitle(InputInterface $input, OutputInterface $output): string; } diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index efa23a5c0..21e092a9c 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -7,6 +7,8 @@ use Mage; use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Command\CommandFormatable; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * List websites command @@ -26,25 +28,25 @@ class ListCommand extends AbstractMagentoCommand implements CommandFormatable public static $defaultDescription = 'Lists all websites.'; /** - * @return string + * {@inheritDoc} */ - public function getSectionTitle(): string + public function getSectionTitle(InputInterface $input, OutputInterface $output): string { return 'Magento Websites'; } /** - * @return string[] + * {@inheritDoc} */ - public function getListHeader(): array + public function getListHeader(InputInterface $input, OutputInterface $output): array { return ['id', 'code']; } /** - * @return array + * {@inheritDoc} */ - public function getListData(): array + public function getListData(InputInterface $input, OutputInterface $output): array { $table = []; foreach (Mage::app()->getWebsites() as $store) { From 4c1e4015b2b6cd1c78789271428513209027931b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 01:58:11 +0200 Subject: [PATCH 12/35] Updated sys:store:list --- .../Command/System/Store/ListCommand.php | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 14f5e507b..f85affabf 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -1,9 +1,12 @@ setName('sys:store:list') - ->setDescription('Lists all installed store-views') - ->addFormatOption() - ; + return ['id', 'code']; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListData(InputInterface $input, OutputInterface $output): array { $table = []; - $this->detectMagento($output, true); - $this->initMagento(); - foreach (Mage::app()->getStores() as $store) { $table[$store->getId()] = [$store->getId(), $store->getCode()]; } ksort($table); - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'code']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } } From 5651ee6b89f0668fd0559bad44f925f9675e40fc Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 01:58:58 +0200 Subject: [PATCH 13/35] Updated cms:block:list --- .../Magento/Command/Cms/Block/ListCommand.php | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index 13feaba95..bfd60ee51 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -1,8 +1,11 @@ setName('cms:block:list') - ->setDescription('List all cms blocks') - ->addFormatOption() - ; + return 'CMS blocks'; } /** - * Get an instance of cms/block - * - * @return \Mage_Cms_Model_Block + * {@inheritDoc} */ - protected function _getBlockModel() + public function getListHeader(InputInterface $input, OutputInterface $output): array { - return $this->_getModel('cms/block', '\Mage_Cms_Model_Block'); + return ['block_id', 'identifier', 'title', 'is_active', 'store_ids']; } /** - * Execute the command - * - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); - - /** @var \Mage_Cms_Model_Resource_Block $resourceModel */ $resourceModel = $this->_getBlockModel()->getResource(); $table = []; foreach ($cmsBlockCollection as $cmsBlock) { $storeIds = implode(',', $resourceModel->lookupStoreIds($cmsBlock->getId())); - $table[] = [$cmsBlock->getData('block_id'), $cmsBlock->getData('identifier'), $cmsBlock->getData('title'), $cmsBlock->getData('is_active') ? 'active' : 'inactive', $storeIds]; + $table[] = [ + $cmsBlock->getData('block_id'), + $cmsBlock->getData('identifier'), + $cmsBlock->getData('title'), + $cmsBlock->getData('is_active') ? 'active' : 'inactive', $storeIds + ]; } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['block_id', 'identifier', 'title', 'is_active', 'store_ids']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; + } + + /** + * Get an instance of cms/block + * + * @return \Mage_Cms_Model_Block + */ + protected function _getBlockModel() + { + return $this->_getModel('cms/block', '\Mage_Cms_Model_Block'); } } From caab9c3ca0aab4acfd707dc9f4760643988c59ae Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 02:06:22 +0200 Subject: [PATCH 14/35] Updated sys:cron:list --- .../Command/System/Cron/ListCommand.php | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index d92e0a9d8..338b53704 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -1,7 +1,10 @@ setName('sys:cron:list') - ->setDescription('Lists all cronjobs') - ->addFormatOption() - ; + return 'Cronjob List'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); + return array_keys(current($this->getListData($input, $output))); + } - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Cronjob List'); + /** + * {@inheritDoc} + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = $this->getJobs(); } - - $this->initMagento(); - - $table = $this->getJobs(); - - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(array_keys(current($table))) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From 09f9d3ef320b775d93e6bc5bc12b675608fc921c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 02:14:33 +0200 Subject: [PATCH 15/35] Updated index:list --- .../Magento/Command/Indexer/ListCommand.php | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 58599e2bb..c528ab996 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -1,7 +1,10 @@ setName('index:list') - ->setDescription('Lists all magento indexes') - ->addFormatOption() - ; + return 'Indexes'; } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function getHelp(): string + public function getListHeader(InputInterface $input, OutputInterface $output): array { - return <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $table = []; foreach ($this->getIndexerList() as $index) { - $table[] = [$index['code'], $index['status'], $index['last_runtime']]; + $table[] = [ + $index['code'], + $index['status'], + $index['last_runtime'] + ]; } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['code', 'status', 'time']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; + } + + /** + * {@inheritdoc} + */ + public function getHelp(): string + { + return << Date: Sat, 10 Aug 2024 02:31:13 +0200 Subject: [PATCH 16/35] Updated AbstractMagentoCommand --- src/N98/Magento/Command/AbstractMagentoCommand.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 0e597e0d2..610d87f1e 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -1,5 +1,7 @@ detectMagento($output, static::$detectMagentoSilent); if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { - $this->writeSection($output, $this->getSectionTitle()); + $this->writeSection($output, $this->getSectionTitle($input, $output)); } if (!$this->initMagento()) { @@ -120,18 +121,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $this->getTableHelper() - ->setHeaders($this->getListHeader()) - ->renderByFormat($output, $this->getListData(), $input->getOption(self::COMMAND_OPTION_FORMAT)); + ->setHeaders($this->getListHeader($input, $output)) + ->renderByFormat($output, $this->getListData($input, $output), $input->getOption(self::COMMAND_OPTION_FORMAT)); return Command::SUCCESS; } + + return Command::INVALID; } private function _initWebsites() { $this->_websiteCodeMap = []; - /** @var \Mage_Core_Model_Website[] $websites */ - $websites = Mage::app()->getWebsites(false); + $websites = Mage::app()->getWebsites(); foreach ($websites as $website) { $this->_websiteCodeMap[$website->getId()] = $website->getCode(); } From 81ba7414c69f431bc9677c5f6c249fb828ba0923 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 02:32:06 +0200 Subject: [PATCH 17/35] Added composer/composer to dev-deps --- composer.json | 1 + composer.lock | 604 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 604 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 27088457f..fcd1c9850 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "require-dev": { "ext-simplexml": "*", "bamarni/symfony-console-autocomplete": "^1.2.0", + "composer/composer": "^2.7", "friendsofphp/php-cs-fixer": "^3.4", "mikey179/vfsstream": "^1.6", "phing/phing": "~2.17.0", diff --git a/composer.lock b/composer.lock index 304de8818..06808c74c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0c12577e0329bb5cf6c8f3a3b788eb99", + "content-hash": "2e4eb914eaf242ad8e42ec4efa3b51ee", "packages": [ { "name": "fakerphp/faker", @@ -2143,6 +2143,338 @@ ], "time": "2022-12-23T10:58:28+00:00" }, + { + "name": "composer/ca-bundle", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/composer/ca-bundle.git", + "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "ext-pcre": "*", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.10", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "symfony/phpunit-bridge": "^4.2 || ^5", + "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\CaBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", + "keywords": [ + "cabundle", + "cacert", + "certificate", + "ssl", + "tls" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/ca-bundle/issues", + "source": "https://github.com/composer/ca-bundle/tree/1.5.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-07-08T15:28:20+00:00" + }, + { + "name": "composer/class-map-generator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/composer/class-map-generator.git", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "shasum": "" + }, + "require": { + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/filesystem": "^5.4 || ^6", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\ClassMapGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Utilities to scan PHP code and generate class maps.", + "keywords": [ + "classmap" + ], + "support": { + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.3.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-06-12T14:13:04+00:00" + }, + { + "name": "composer/composer", + "version": "2.7.7", + "source": { + "type": "git", + "url": "https://github.com/composer/composer.git", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/composer/zipball/291942978f39435cf904d33739f98d7d4eca7b23", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23", + "shasum": "" + }, + "require": { + "composer/ca-bundle": "^1.0", + "composer/class-map-generator": "^1.3.3", + "composer/metadata-minifier": "^1.0", + "composer/pcre": "^2.1 || ^3.1", + "composer/semver": "^3.3", + "composer/spdx-licenses": "^1.5.7", + "composer/xdebug-handler": "^2.0.2 || ^3.0.3", + "justinrainbow/json-schema": "^5.2.11", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "react/promise": "^2.8 || ^3", + "seld/jsonlint": "^1.4", + "seld/phar-utils": "^1.2", + "seld/signal-handler": "^2.0", + "symfony/console": "^5.4.11 || ^6.0.11 || ^7", + "symfony/filesystem": "^5.4 || ^6.0 || ^7", + "symfony/finder": "^5.4 || ^6.0 || ^7", + "symfony/polyfill-php73": "^1.24", + "symfony/polyfill-php80": "^1.24", + "symfony/polyfill-php81": "^1.24", + "symfony/process": "^5.4 || ^6.0 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.11.0", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-symfony": "^1.4.0", + "symfony/phpunit-bridge": "^6.4.1 || ^7.0.1" + }, + "suggest": { + "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", + "ext-zip": "Enabling the zip extension allows you to unzip archives", + "ext-zlib": "Allow gzip compression of HTTP requests" + }, + "bin": [ + "bin/composer" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.7-dev" + }, + "phpstan": { + "includes": [ + "phpstan/rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Composer\\": "src/Composer/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "https://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.", + "homepage": "https://getcomposer.org/", + "keywords": [ + "autoload", + "dependency", + "package" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/composer/issues", + "security": "https://github.com/composer/composer/security/policy", + "source": "https://github.com/composer/composer/tree/2.7.7" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-06-10T20:11:12+00:00" + }, + { + "name": "composer/metadata-minifier", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/metadata-minifier.git", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2", + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\MetadataMinifier\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Small utility library that handles metadata minification and expansion.", + "keywords": [ + "composer", + "compression" + ], + "support": { + "issues": "https://github.com/composer/metadata-minifier/issues", + "source": "https://github.com/composer/metadata-minifier/tree/1.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-04-07T13:37:33+00:00" + }, { "name": "composer/pcre", "version": "3.2.0", @@ -2303,6 +2635,86 @@ ], "time": "2024-07-12T11:35:52+00:00" }, + { + "name": "composer/spdx-licenses", + "version": "1.5.8", + "source": { + "type": "git", + "url": "https://github.com/composer/spdx-licenses.git", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Spdx\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "SPDX licenses list and validation library.", + "keywords": [ + "license", + "spdx", + "validator" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/spdx-licenses/issues", + "source": "https://github.com/composer/spdx-licenses/tree/1.5.8" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-11-20T07:44:33+00:00" + }, { "name": "composer/xdebug-handler", "version": "3.0.5", @@ -2650,6 +3062,71 @@ ], "time": "2024-07-31T14:33:15+00:00" }, + { + "name": "justinrainbow/json-schema", + "version": "5.3.0", + "source": { + "type": "git", + "url": "https://github.com/jsonrainbow/json-schema.git", + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/5.3.0" + }, + "time": "2024-07-06T21:00:26+00:00" + }, { "name": "mikey179/vfsstream", "version": "v1.6.11", @@ -5073,6 +5550,70 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "seld/jsonlint", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" + }, + "bin": [ + "bin/jsonlint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], + "support": { + "issues": "https://github.com/Seldaek/jsonlint/issues", + "source": "https://github.com/Seldaek/jsonlint/tree/1.11.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", + "type": "tidelift" + } + ], + "time": "2024-07-11T14:55:45+00:00" + }, { "name": "seld/phar-utils", "version": "1.2.1", @@ -5121,6 +5662,67 @@ }, "time": "2022-08-31T10:31:18+00:00" }, + { + "name": "seld/signal-handler", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/signal-handler.git", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "require-dev": { + "phpstan/phpstan": "^1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^7.5.20 || ^8.5.23", + "psr/log": "^1 || ^2 || ^3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Seld\\Signal\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Simple unix signal handler that silently fails where signals are not supported for easy cross-platform development", + "keywords": [ + "posix", + "sigint", + "signal", + "sigterm", + "unix" + ], + "support": { + "issues": "https://github.com/Seldaek/signal-handler/issues", + "source": "https://github.com/Seldaek/signal-handler/tree/2.0.2" + }, + "time": "2023-09-03T09:24:00+00:00" + }, { "name": "symfony/filesystem", "version": "v5.4.41", From dd5c13eb9cd7d617d3b93f4254ba789f8200a75a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 10 Aug 2024 02:38:17 +0200 Subject: [PATCH 18/35] Updated dev:theme:list --- .../Command/Developer/Theme/ListCommand.php | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 3230d76ff..3430f2842 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -1,9 +1,12 @@ setName('dev:theme:list') - ->setDescription('Lists all available themes') - ->addFormatOption() - ; + return 'Themes'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + return ['label']; + } + /** + * {@inheritDoc} + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { $packages = $this->getThemes(); $table = []; foreach ($packages as $package => $themes) { @@ -43,17 +56,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['Theme']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } /** * @return array */ - protected function getThemes() + protected function getThemes(): array { if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { $collection = Mage::getModel('Mage_Core_Model_Theme')->getLabelsCollection(); From bbf411d9e4eb1a89b3f83cd7dc28748d792a45bd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 11 Aug 2024 00:49:20 +0200 Subject: [PATCH 19/35] Updated AbstractAdminUserCommand --- .../Admin/User/AbstractAdminUserCommand.php | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 699b5e471..13bd2e3b2 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -1,7 +1,13 @@ _getModel('admin/user', 'Mage_User_Model_User'); + return Mage::getModel('admin/user'); } /** - * @return \Mage_Core_Model_Abstract + * @return Mage_Admin_Model_Roles */ - protected function getRoleModel() + protected function getRoleModel(): Mage_Admin_Model_Roles { - return $this->_getModel('admin/roles', 'Mage_User_Model_Role'); + return Mage::getModel('admin/roles'); } /** - * @return \Mage_Core_Model_Abstract + * @return Mage_Admin_Model_Rules */ - protected function getRulesModel() + protected function getRulesModel(): Mage_Admin_Model_Rules { - return $this->_getModel('admin/rules', 'Mage_User_Model_Rules'); + return Mage::getModel('admin/rules'); } } From 10fe55c26e8da7e6767b1c293db7f705aef50e8e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 11 Aug 2024 01:34:37 +0200 Subject: [PATCH 20/35] Minor changes --- src/N98/Magento/Command/AbstractMagentoCommand.php | 14 ++++++++++++-- src/N98/Magento/Command/Admin/User/ListCommand.php | 2 +- .../Magento/Command/System/Store/ListCommand.php | 8 +++++++- .../Magento/Command/System/Website/ListCommand.php | 11 +++++++---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 610d87f1e..e6048019a 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -112,7 +112,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this instanceof CommandFormatable) { $this->detectMagento($output, static::$detectMagentoSilent); - if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { + $formatOption = $input->getOption(static::COMMAND_OPTION_FORMAT); + + if ($formatOption === null) { $this->writeSection($output, $this->getSectionTitle($input, $output)); } @@ -120,9 +122,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::FAILURE; } + $data = $this->getListData($input, $output); + if ($formatOption === null && $data === []) { + $output->writeln(sprintf( + 'No entry found for "%s" ', + $this->getSectionTitle($input, $output)) + ); + } + $this->getTableHelper() ->setHeaders($this->getListHeader($input, $output)) - ->renderByFormat($output, $this->getListData($input, $output), $input->getOption(self::COMMAND_OPTION_FORMAT)); + ->renderByFormat($output, $data, $input->getOption(self::COMMAND_OPTION_FORMAT)); return Command::SUCCESS; } diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 296269caf..27c0a4e69 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -47,10 +47,10 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a */ public function getListData(InputInterface $input, OutputInterface $output): array { - /** @var Mage_Admin_Model_User $userModel */ $userModel = $this->getUserModel(); $userList = $userModel->getCollection(); $table = []; + /** @var Mage_Admin_Model_User $user */ foreach ($userList as $user) { $table[] = [ $user->getId(), diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index f85affabf..124f6c943 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function ksort; + /** * List stores command * @@ -50,7 +52,11 @@ public function getListData(InputInterface $input, OutputInterface $output): arr { $table = []; foreach (Mage::app()->getStores() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode()]; + $storeId = $store->getId(); + $table[$storeId] = [ + $storeId, + $store->getCode() + ]; } ksort($table); diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 21e092a9c..8ed16cdd4 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function ksort; + /** * List websites command * @@ -49,10 +51,11 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a public function getListData(InputInterface $input, OutputInterface $output): array { $table = []; - foreach (Mage::app()->getWebsites() as $store) { - $table[$store->getId()] = [ - $store->getId(), - $store->getCode() + foreach (Mage::app()->getWebsites() as $website) { + $websiteId = $website->getId(); + $table[$websiteId] = [ + $websiteId, + $website->getCode() ]; } From 3d7c0020548f62cf481ea8c35a8b916c5627d4fd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 11 Aug 2024 02:24:41 +0200 Subject: [PATCH 21/35] Updated script:repo:list --- .../Command/Script/Repository/ListCommand.php | 85 ++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index 87e005a2e..699324ce7 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -1,9 +1,10 @@ setName('script:repo:list') - ->setDescription('Lists all scripts in repository') - ->addFormatOption() - ; + $table = []; + $files = $this->getScripts(); + if (count($files) > 0) { + foreach ($files as $file) { + $table[] = [ + substr($file['fileinfo']->getFilename(), 0, -strlen(self::MAGERUN_EXTENSION)), + $file['location'], + $file['description'] + ]; + } + } + + return $table; } /** @@ -41,33 +79,4 @@ public function getHelp(): string $ n98-magerun.phar script:repo:list HELP; } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $files = $this->getScripts(); - if (count($files) > 0) { - $table = []; - foreach ($files as $file) { - $table[] = [substr($file['fileinfo']->getFilename(), 0, -strlen(self::MAGERUN_EXTENSION)), $file['location'], $file['description']]; - } - } else { - $table = []; - } - - if ($input->getOption('format') === null && count($table) === 0) { - $output->writeln('no script file found'); - } - - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['Script', Location::class, Description::class]) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; - } } From df447e4f30ccfb117b6feb96e97ab79c283721d2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 02:21:02 +0200 Subject: [PATCH 22/35] Updated sys:cron:history --- .../Command/System/Cron/HistoryCommand.php | 93 ++++++++++++------- .../Command/System/Cron/ListCommand.php | 4 +- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index 3415eef1a..9386af57f 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -1,77 +1,100 @@ setName('sys:cron:history') - ->setDescription('Last executed cronjobs with status.') - ->addOption( - 'timezone', - null, - InputOption::VALUE_OPTIONAL, - 'Timezone to show finished at in' - ) - ->addFormatOption() - ; + $this->addOption( + self::COMMAND_OPTION_TIMEZONE, + null, + InputOption::VALUE_OPTIONAL, + 'Timezone to show finished at in' + ); + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getSectionTitle(InputInterface $input, OutputInterface $output): string { - $this->detectMagento($output, true); + return 'Last executed jobs'; + } - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Last executed jobs'); - } - $this->initMagento(); + /** + * {@inheritDoc} + */ + public function getListHeader(InputInterface $input, OutputInterface $output): array + { + return ['Job', 'Status', 'Finished']; + } - $timezone = $input->getOption('timezone') ?: Mage::app()->getStore()->getConfig('general/locale/timezone'); + /** + * {@inheritDoc} + * @throws Mage_Core_Model_Store_Exception|Mage_Core_Exception + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) + ?: Mage::app()->getStore()->getConfig('general/locale/timezone'); - $output->writeln('Times shown in ' . $timezone . ''); + $output->writeln(sprintf('Times shown in %s', $timezone)); $date = Mage::getSingleton('core/date'); $offset = $date->calculateOffset($timezone); $collection = Mage::getModel('cron/schedule')->getCollection(); $collection ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) - ->addOrder('finished_at', Varien_Data_Collection_Db::SORT_ORDER_DESC); + ->addOrder('finished_at'); $table = []; + /** @var Mage_Cron_Model_Schedule $job */ foreach ($collection as $job) { - $table[] = [$job->getJobCode(), $job->getStatus(), $job->getFinishedAt() ? $date->gmtDate(null, $date->timestamp($job->getFinishedAt()) + $offset) : '']; + $table[] = [ + $job->getJobCode(), + $job->getStatus(), + $job->getFinishedAt() ? $date->gmtDate( + null, + $date->timestamp($job->getFinishedAt()) + $offset + ) : '' + ]; } - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['Job', 'Status', 'Finished']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $table; } } diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 338b53704..9fbe5a1cb 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -18,12 +18,12 @@ class ListCommand extends AbstractCronCommand implements CommandFormatable /** * @var string */ - public static $defaultName = 'sys:cron:list'; + protected static $defaultName = 'sys:cron:list'; /** * @var string */ - public static $defaultDescription = 'Lists all cronjobs.'; + protected static $defaultDescription = 'Lists all cronjobs.'; /** * @var array|null From ad92faaaaf03ebb60b70b7da02f28bb6bcbde8ca Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 03:17:19 +0200 Subject: [PATCH 23/35] Updated sys:cron:list [skip ci] --- .../Magento/Command/AbstractMagentoCommand.php | 5 +++++ .../Magento/Command/Admin/User/ListCommand.php | 14 +++++++++----- .../Command/System/Cron/HistoryCommand.php | 13 ++++++++++--- .../Magento/Command/System/Cron/ListCommand.php | 15 ++++++++------- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index e6048019a..797567ed0 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -81,6 +81,11 @@ abstract class AbstractMagentoCommand extends Command */ protected $config; + /** + * @var array|null + */ + protected ?array $data = null; + /** * @var bool */ diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 27c0a4e69..15e084fb7 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -19,12 +19,12 @@ class ListCommand extends AbstractAdminUserCommand implements CommandFormatable /** * @var string */ - public static $defaultName = 'admin:user:list'; + protected static $defaultName = 'admin:user:list'; /** * @var string */ - public static $defaultDescription = 'List admin users.'; + protected static $defaultDescription = 'List admin users.'; /** * {@inheritDoc} @@ -47,12 +47,16 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a */ public function getListData(InputInterface $input, OutputInterface $output): array { + if (is_array($this->data)) { + return $this->data; + } + $userModel = $this->getUserModel(); $userList = $userModel->getCollection(); - $table = []; + $this->data = []; /** @var Mage_Admin_Model_User $user */ foreach ($userList as $user) { - $table[] = [ + $this->data[] = [ $user->getId(), $user->getUsername(), $user->getEmail(), @@ -60,6 +64,6 @@ public function getListData(InputInterface $input, OutputInterface $output): arr ]; } - return $table; + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index 9386af57f..f94fee03f 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -14,6 +14,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function is_array; +use function sprintf; + /** * List cronjob history command * @@ -70,6 +73,10 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a */ public function getListData(InputInterface $input, OutputInterface $output): array { + if (is_array($this->data)) { + return $this->data; + } + $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) ?: Mage::app()->getStore()->getConfig('general/locale/timezone'); @@ -82,10 +89,10 @@ public function getListData(InputInterface $input, OutputInterface $output): arr ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) ->addOrder('finished_at'); - $table = []; + $this->data = []; /** @var Mage_Cron_Model_Schedule $job */ foreach ($collection as $job) { - $table[] = [ + $this->data[] = [ $job->getJobCode(), $job->getStatus(), $job->getFinishedAt() ? $date->gmtDate( @@ -95,6 +102,6 @@ public function getListData(InputInterface $input, OutputInterface $output): arr ]; } - return $table; + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 9fbe5a1cb..c13a5f359 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -8,6 +8,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function array_keys; +use function current; +use function is_array; + /** * List cronjob command * @@ -25,11 +29,6 @@ class ListCommand extends AbstractCronCommand implements CommandFormatable */ protected static $defaultDescription = 'Lists all cronjobs.'; - /** - * @var array|null - */ - public ?array $data = null; - /** * {@inheritDoc} */ @@ -51,9 +50,11 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a */ public function getListData(InputInterface $input, OutputInterface $output): array { - if (is_null($this->data)) { - $this->data = $this->getJobs(); + if (is_array($this->data)) { + return $this->data; } + + $this->data = $this->getJobs(); return $this->data; } } From b6b2ade4cdf6c70f0f51135075dc85c953dc463f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 03:21:45 +0200 Subject: [PATCH 24/35] Updated sys:store:config:base-url:list --- .../Command/AbstractMagentoCommand.php | 2 +- .../Store/Config/BaseUrlListCommand.php | 65 ++++++++++++------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 797567ed0..73c4e9722 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -737,7 +737,7 @@ protected function createSubCommandFactory( public function addFormatOption(): self { $this->addOption( - 'format', + self::COMMAND_OPTION_FORMAT, null, InputOption::VALUE_OPTIONAL, 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 4c92bbe85..077985c3e 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -1,54 +1,73 @@ setName('sys:store:config:base-url:list') - ->setDescription('Lists all base urls') - ->addFormatOption() - ; + return 'Magento Stores - Base URLs'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(InputInterface $input, OutputInterface $output): array { - $table = []; - $this->detectMagento($output, true); + return ['id', 'code', 'unsecure_baseurl', 'secure_baseurl']; + } - if (!$input->getOption('format')) { - $this->writeSection($output, 'Magento Stores - Base URLs'); + /** + * {@inheritDoc} + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + if (is_array($this->data)) { + return $this->data; } - $this->initMagento(); + $table = []; foreach (Mage::app()->getStores() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode(), Mage::getStoreConfig('web/unsecure/base_url', $store), Mage::getStoreConfig('web/secure/base_url', $store)]; + $table[$store->getId()] = [ + $store->getId(), + $store->getCode(), + Mage::getStoreConfig('web/unsecure/base_url', $store), + Mage::getStoreConfig('web/secure/base_url', $store) + ]; } ksort($table); + $this->data = $table; - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'code', 'unsecure_baseurl', 'secure_baseurl']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From 2e6a857307373f76bff1faeea278dbe7096fcd93 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 14 Aug 2024 01:23:04 +0200 Subject: [PATCH 25/35] Updated dev:email-template:usage --- .../Command/AbstractMagentoCommand.php | 20 +++- .../Command/Admin/User/ListCommand.php | 2 + .../Developer/EmailTemplate/UsageCommand.php | 91 +++++++++++++------ 3 files changed, 79 insertions(+), 34 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 73c4e9722..df7fedd73 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -86,6 +86,11 @@ abstract class AbstractMagentoCommand extends Command */ protected ?array $data = null; + /** + * @var string + */ + protected static string $noResultMessage = ''; + /** * @var bool */ @@ -129,10 +134,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $data = $this->getListData($input, $output); if ($formatOption === null && $data === []) { - $output->writeln(sprintf( - 'No entry found for "%s" ', - $this->getSectionTitle($input, $output)) - ); + if (static::$noResultMessage) { + $output->writeln(sprintf( + '%s', + static::$noResultMessage + )); + } else { + $output->writeln(sprintf( + 'No entry found for "%s" ', + $this->getSectionTitle($input, $output) + )); + } } $this->getTableHelper() diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 15e084fb7..409d927c7 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_array; + /** * List admin user password command * diff --git a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php index 9e69760ef..ad2fe88bd 100644 --- a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php +++ b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php @@ -1,15 +1,20 @@ setName('dev:email-template:usage') - ->setDescription('Display database transactional email template usage') - ->addFormatOption(); + return 'Transactional email templates'; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - $this->initMagento(); - $templates = $this->findEmailTemplates(); - - if (!empty($templates)) { - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'Name', 'Scope', 'Scope Id', Path::class]) - ->renderByFormat($output, $templates, $input->getOption('format')); - } else { - $output->writeln('No transactional email templates stored in the database.'); + return ['id', 'Name', 'Scope', 'Scope Id', 'Path']; + } + + /** + * {@inheritDoc} + * @throws Mage_Core_Exception + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + if (is_array($this->data)) { + return $this->data; } - return 0; + + $this->data = $this->findEmailTemplates(); + return $this->data; } - protected function findEmailTemplates() + /** + * @throws Mage_Core_Exception + */ + protected function findEmailTemplates(): array { /** @var Mage_Core_Model_Template[] $templates */ $templates = Mage::getModel('adminhtml/email_template')->getCollection(); @@ -59,8 +81,7 @@ protected function findEmailTemplates() $return = []; foreach ($templates as $template) { - - /** + /* * Some modules overload the template class so that the method getSystemConfigPathsWhereUsedCurrently * is not available, this is a workaround for that */ @@ -72,11 +93,21 @@ protected function findEmailTemplates() $configPaths = $template->getSystemConfigPathsWhereUsedCurrently(); if (!(is_countable($configPaths) ? count($configPaths) : 0)) { - $configPaths[] = ['scope' => 'Unused', 'scope_id' => 'Unused', 'path' => 'Unused']; + $configPaths[] = [ + 'scope' => 'Unused', + 'scope_id' => 'Unused', + 'path' => 'Unused' + ]; } foreach ($configPaths as $configPath) { - $return[] = ['id' => $this->sanitizeEmailProperty($template->getId()), 'Template Code' => $this->sanitizeEmailProperty($template->getTemplateCode()), 'Scope' => $this->sanitizeEmailProperty($configPath['scope']), 'Scope Id' => $this->sanitizeEmailProperty($configPath['scope_id']), Path::class => $this->sanitizeEmailProperty($configPath['path'])]; + $return[] = [ + 'id' => $this->sanitizeEmailProperty($template->getId()), + 'Template Code' => $this->sanitizeEmailProperty($template->getTemplateCode()), + 'Scope' => $this->sanitizeEmailProperty($configPath['scope']), + 'Scope Id' => $this->sanitizeEmailProperty($configPath['scope_id']), + 'Path' => $this->sanitizeEmailProperty($configPath['path']) + ]; } } @@ -88,7 +119,7 @@ protected function findEmailTemplates() * * @return string */ - private function sanitizeEmailProperty($input) + private function sanitizeEmailProperty(string $input): string { return trim($input); } From 9c84d918fa765446891f6a68dc541733a0f28a8e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 14 Aug 2024 01:40:43 +0200 Subject: [PATCH 26/35] Updated dev:module:rewrite:list --- .../Developer/Module/Rewrite/ListCommand.php | 80 ++++++++++++------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index 83a9ca791..fe16d0d33 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -1,63 +1,81 @@ setName('dev:module:rewrite:list') - ->setDescription('Lists all magento rewrites') - ->addFormatOption() - ; + return ['Type', 'Class', 'Rewrite']; } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; + if (is_array($this->data)) { + return $this->data; } $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); - $table = []; + $this->data = []; foreach ($rewrites as $type => $data) { if ((is_countable($data) ? count($data) : 0) > 0) { foreach ($data as $class => $rewriteClass) { - $table[] = [$type, $class, implode(', ', $rewriteClass)]; + $this->data[] = [ + $type, + $class, + implode(', ', $rewriteClass) + ]; } } } - if (count($table) === 0 && $input->getOption('format') === null) { - $output->writeln('No rewrites were found.'); - } else { - if (count($table) == 0) { - $table = []; - } - - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['Type', 'Class', 'Rewrite']) - ->setRows($table) - ->renderByFormat($output, $table, $input->getOption('format')); - } - return 0; + return $this->data; } } From 5cf802e2e82d3bede3773d986c013d15226890c6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 14 Aug 2024 02:12:43 +0200 Subject: [PATCH 27/35] Updated dev:module:list --- .../Command/Developer/Module/ListCommand.php | 104 ++++++++++++------ src/N98/Magento/Modules.php | 39 +++++-- 2 files changed, 100 insertions(+), 43 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 5fc4850ac..28e9c6384 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -1,59 +1,102 @@ setName('dev:module:list') - ->addOption('codepool', null, InputOption::VALUE_OPTIONAL, 'Show modules in a specific codepool') - ->addOption('status', null, InputOption::VALUE_OPTIONAL, 'Show modules with a specific status') - ->addOption('vendor', null, InputOption::VALUE_OPTIONAL, 'Show modules of a specified vendor') - ->setAliases(['sys:modules:list'])// deprecated - ->setDescription('List all installed modules') - ->addFormatOption(); + ->addOption( + self::COMMAND_OPTION_COODPOOL, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules in a specific codepool' + ) + ->addOption( + self::COMMAND_OPTION_STATUS, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules with a specific status' + ) + ->addOption( + self::COMMAND_OPTION_VENDOR, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules of a specified vendor' + ) + ->setAliases(['sys:modules:list']); // deprecated + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritDoc} + */ + public function getSectionTitle(InputInterface $input, OutputInterface $output): string + { + return 'Installed Modules'; + } + + /** + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getListHeader(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); + return ['codePool', 'Name', 'Version', 'Status']; + } - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Magento Modules'); + /** + * {@inheritDoc} + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + if (is_array($this->data)) { + return $this->data; } - $this->initMagento(); $modules = $this->filterModules($input); + $this->data = iterator_to_array($modules); - if (!count($modules)) { - $output->writeln('No modules match the specified criteria.'); - return 0; - } - - $table = $this->getTableHelper(); - $table - ->setHeaders(['codePool', 'Name', 'Version', 'Status']) - ->renderByFormat($output, iterator_to_array($modules), $input->getOption('format')); - return 0; + return $this->data; } /** @@ -61,12 +104,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @return Modules */ - private function filterModules(InputInterface $input) + private function filterModules(InputInterface $input): Modules { $modules = new Modules(); - $modules = $modules->findInstalledModules() + return $modules + ->findInstalledModules() ->filterModules($input); - - return $modules; } } diff --git a/src/N98/Magento/Modules.php b/src/N98/Magento/Modules.php index 7f1ca6537..642d47e08 100644 --- a/src/N98/Magento/Modules.php +++ b/src/N98/Magento/Modules.php @@ -1,16 +1,23 @@ trim($codePool), 'Name' => trim($moduleName), 'Version' => trim($version), 'Status' => StringTyped::formatActive($active)]; + $list[] = [ + 'codePool' => trim($codePool), + 'Name' => trim($moduleName), + 'Version' => trim($version), + 'Status' => StringTyped::formatActive($active) + ]; } return new Modules($list); @@ -59,20 +71,23 @@ public function findInstalledModules() * @param InputInterface $input * @return Modules */ - public function filterModules(InputInterface $input) + public function filterModules(InputInterface $input): Modules { $filtered = $this->list; - if ($input->getOption('codepool')) { - $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'codePool', $input->getOption('codepool')); + $codepool = $input->getOption(ListCommand::COMMAND_OPTION_COODPOOL); + if ($codepool) { + $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'codePool', $codepool); } - if ($input->getOption('status')) { - $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'Status', $input->getOption('status')); + $status = $input->getOption(ListCommand::COMMAND_OPTION_STATUS); + if ($status) { + $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'Status', $status); } - if ($input->getOption('vendor')) { - $filtered = ArrayFunctions::matrixFilterStartswith($filtered, 'Name', $input->getOption('vendor')); + $vendor = $input->getOption(ListCommand::COMMAND_OPTION_VENDOR); + if ($vendor) { + $filtered = ArrayFunctions::matrixFilterStartswith($filtered, 'Name', $vendor); } return new self($filtered); From e81a1a2743d63f3ac96e446aa150a57d82beabf5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 14 Aug 2024 02:44:39 +0200 Subject: [PATCH 28/35] Updated customer:list --- .../Magento/Command/Customer/ListCommand.php | 115 ++++++++++++------ .../Command/Developer/Module/ListCommand.php | 5 +- 2 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index 502b9ac7b..5b26cfe33 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -1,50 +1,80 @@ setName('customer:list') - ->addArgument('search', InputArgument::OPTIONAL, 'Search query') - ->addFormatOption() - ->setDescription('Lists customers') - ; + $this->addArgument( + self::COMMAND_ARGUMENT_SEARCH, + InputArgument::OPTIONAL, + 'Search query' + ); + + parent::configure(); } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function getHelp(): string + public function getSectionTitle(InputInterface $input, OutputInterface $output): string { - return <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; + return ['id', 'email', 'firstname', 'lastname', 'website']; + } + + /** + * {@inheritDoc} + * @throws Mage_Core_Exception + */ + public function getListData(InputInterface $input, OutputInterface $output): array + { + if (is_array($this->data)) { + return $this->data; } $config = $this->getCommandConfig(); @@ -52,27 +82,42 @@ protected function execute(InputInterface $input, OutputInterface $output): int $collection = $this->getCustomerCollection(); $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - if ($input->getArgument('search')) { + $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); + if ($search) { $collection->addAttributeToFilter( - [['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%']] + [ + ['attribute' => 'email', 'like' => '%' . $search . '%'], + ['attribute' => 'firstname', 'like' => '%' . $search . '%'], + ['attribute' => 'lastname', 'like' => '%' . $search . '%'] + ] ); } $collection->setPageSize($config['limit']); - $table = []; + $this->data = []; + /** @var Mage_Customer_Model_Customer $customer */ foreach ($collection as $customer) { - $table[] = [$customer->getId(), $customer->getEmail(), $customer->getFirstname(), $customer->getLastname(), $this->_getWebsiteCodeById($customer->getwebsiteId())]; + $this->data[] = [ + $customer->getId(), + $customer->getEmail(), + $customer->getFirstname(), + $customer->getLastname(), + $this->_getWebsiteCodeById($customer->getwebsiteId()) + ]; } - if (count($table) > 0) { - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'email', 'firstname', 'lastname', 'website']) - ->renderByFormat($output, $table, $input->getOption('format')); - } else { - $output->writeln('No customers found'); - } - return 0; + return $this->data; + } + + /** + * {@inheritdoc} + */ + public function getHelp(): string + { + return <<addOption( From 30833e8847ebf0b2ddea662203adcc7b4e9a64de Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 15 Aug 2024 01:40:54 +0200 Subject: [PATCH 29/35] Fixed tests --- .../Magento/Command/Admin/User/AbstractAdminUserCommand.php | 6 +++--- src/N98/Magento/Command/Admin/User/ListCommand.php | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 13bd2e3b2..d62bf6c90 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -20,7 +20,7 @@ abstract class AbstractAdminUserCommand extends AbstractMagentoCommand /** * @return Mage_Admin_Model_User */ - protected function getUserModel(): Mage_Admin_Model_User + protected function getUserModel() { return Mage::getModel('admin/user'); } @@ -28,7 +28,7 @@ protected function getUserModel(): Mage_Admin_Model_User /** * @return Mage_Admin_Model_Roles */ - protected function getRoleModel(): Mage_Admin_Model_Roles + protected function getRoleModel() { return Mage::getModel('admin/roles'); } @@ -36,7 +36,7 @@ protected function getRoleModel(): Mage_Admin_Model_Roles /** * @return Mage_Admin_Model_Rules */ - protected function getRulesModel(): Mage_Admin_Model_Rules + protected function getRulesModel() { return Mage::getModel('admin/rules'); } diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 409d927c7..dbae585cf 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -28,6 +28,11 @@ class ListCommand extends AbstractAdminUserCommand implements CommandFormatable */ protected static $defaultDescription = 'List admin users.'; + /** + * @var string + */ + protected static string $noResultMessage = 'No admin users found.'; + /** * {@inheritDoc} */ From 36a4a263c1bbf26282ace8aaf8a8f09b0a88068b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 12 Nov 2024 21:41:23 +0100 Subject: [PATCH 30/35] Updated test --- tests/N98/Util/AutoloadHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/N98/Util/AutoloadHandlerTest.php b/tests/N98/Util/AutoloadHandlerTest.php index 2564958cc..d1fcf0fb9 100644 --- a/tests/N98/Util/AutoloadHandlerTest.php +++ b/tests/N98/Util/AutoloadHandlerTest.php @@ -106,7 +106,7 @@ public function changingCallback() $handler = $this->create(null, AutoloadHandler::NO_EXCEPTION); self::assertFalse($handler->__invoke('Test')); - self::assertObjectNotHasAttribute('count', $calls); + self::assertObjectNotHasProperty('count', $calls); $handler->setCallback($assertAble); self::assertTrue($handler->__invoke('Test')); From b24939534a8ca1c58435a30621435d3ef7f1ee87 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 12 Nov 2024 21:48:39 +0100 Subject: [PATCH 31/35] Fixed test (?) --- tests/N98/Magento/ModulesTest.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php index 60072186d..618594ec1 100644 --- a/tests/N98/Magento/ModulesTest.php +++ b/tests/N98/Magento/ModulesTest.php @@ -93,17 +93,12 @@ private function filter($option = null, $value = null) $i = 0; foreach ($options as $opt => $val) { - $input - ->expects(self::at($i++)) - ->method('getOption') - ->with($opt) - ->willReturn($val); - if (!$val) { continue; } - $input->expects(self::at($i++)) + $input + ->expects(self::at($i++)) ->method('getOption') ->with($opt) ->willReturn($val); From f5747983e2ff7b26e77decddc141f03e1c9fa779 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 12 Nov 2024 22:00:44 +0100 Subject: [PATCH 32/35] Fixed test (?) --- tests/N98/Magento/ModulesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php index 618594ec1..ac836c79f 100644 --- a/tests/N98/Magento/ModulesTest.php +++ b/tests/N98/Magento/ModulesTest.php @@ -98,7 +98,7 @@ private function filter($option = null, $value = null) } $input - ->expects(self::at($i++)) + ->expects(self::any()) ->method('getOption') ->with($opt) ->willReturn($val); From 2318443b41c01844af63d33803ffbbac75d4c6b4 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 12 Nov 2024 22:11:40 +0100 Subject: [PATCH 33/35] Fixed test (?) --- tests/N98/Magento/ModulesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php index ac836c79f..830b55cc7 100644 --- a/tests/N98/Magento/ModulesTest.php +++ b/tests/N98/Magento/ModulesTest.php @@ -85,7 +85,7 @@ private function filter($option = null, $value = null) $options[$option] = $value; } - /** @var $input PHPUnit_Framework_MockObject_MockObject|ArrayInput */ + /** @var PHPUnit_Framework_MockObject_MockObject|ArrayInput $input */ $input = $this->getMockBuilder(ArrayInput::class) ->disableOriginalConstructor() ->setMethods(['getOption']) @@ -98,7 +98,7 @@ private function filter($option = null, $value = null) } $input - ->expects(self::any()) + ->expects(self::at($i++)) ->method('getOption') ->with($opt) ->willReturn($val); From b78bef87024839c56c351103de9f18f9ff2a357a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 4 Feb 2025 13:11:58 +0100 Subject: [PATCH 34/35] updated test --- tests/N98/Magento/ModulesTest.php | 36 +++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php index 830b55cc7..339961dc0 100644 --- a/tests/N98/Magento/ModulesTest.php +++ b/tests/N98/Magento/ModulesTest.php @@ -47,20 +47,52 @@ public function filteringCountAndIterating() /** * @test */ - public function findInstalledModulesAndFilterThem() + public function findInstalledModulesAndCount() { $this->getApplication()->initMagento(); - $modules = new Modules(); self::assertCount(0, $modules); + $total = count($modules->findInstalledModules()); self::assertGreaterThan(10, $total); + } + + /** + * @test + */ + public function findInstalledModulesAndFilterByCodepool() + { + $this->getApplication()->initMagento(); + $modules = new Modules(); + $total = count($modules->findInstalledModules()); + $filtered = $modules->filterModules($this->filter('codepool', 'core')); self::assertLessThan($total, count($filtered)); + } + + /** + * @test + */ + public function findInstalledModulesAndFilterByStatus() + { + $this->getApplication()->initMagento(); + $modules = new Modules(); + $total = count($modules->findInstalledModules()); + $filtered = $modules->filterModules($this->filter('status', 'active')); self::assertLessThan($total, count($filtered)); + } + + /** + * @test + */ + public function findInstalledModulesAndFilterByVendor() + { + $this->getApplication()->initMagento(); + $modules = new Modules(); + $total = count($modules->findInstalledModules()); $filtered = $modules->filterModules($this->filter('vendor', 'Mage_')); self::assertLessThan($total, count($filtered)); From 4e4a2400484540e555346b08d665e6cea18ab46d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 4 Feb 2025 13:21:03 +0100 Subject: [PATCH 35/35] updated test ... test --- tests/N98/Magento/ModulesTest.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php index 339961dc0..7d89fb091 100644 --- a/tests/N98/Magento/ModulesTest.php +++ b/tests/N98/Magento/ModulesTest.php @@ -123,18 +123,11 @@ private function filter($option = null, $value = null) ->setMethods(['getOption']) ->getMock(); - $i = 0; - foreach ($options as $opt => $val) { - if (!$val) { - continue; - } - - $input - ->expects(self::at($i++)) - ->method('getOption') - ->with($opt) - ->willReturn($val); - } + $input + ->expects(self::any()) + ->method('getOption') + ->with($option) + ->willReturn($options[$option]); return $input; }