From 1377cc59f6b351d71ef80d74b4b63b9f0c22245e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 16 Dec 2023 17:43:02 +0100 Subject: [PATCH] Filter non action classes in route:list output (#1304) --- src/N98/Magento/Command/Route/ListCommand.php | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/N98/Magento/Command/Route/ListCommand.php b/src/N98/Magento/Command/Route/ListCommand.php index 36a3cbc8..4295d576 100644 --- a/src/N98/Magento/Command/Route/ListCommand.php +++ b/src/N98/Magento/Command/Route/ListCommand.php @@ -2,6 +2,7 @@ namespace N98\Magento\Command\Route; +use Magento\Framework\App\ActionInterface; use Magento\Framework\App\AreaList; use Magento\Framework\App\Route\Config; use Magento\Framework\Module\Dir\Reader; @@ -15,22 +16,22 @@ class ListCommand extends AbstractMagentoCommand { /** - * @var \Magento\Framework\Module\Dir\Reader + * @var Reader */ private $reader; /** - * @var \Magento\Framework\App\Route\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\App\AreaList + * @var AreaList */ private $areaList; /** - * @var \Magento\Framework\App\Route\Config\Reader + * @var Config\Reader */ private $configReader; @@ -65,10 +66,10 @@ protected function configure() * @return void */ public function inject( - \Magento\Framework\Module\Dir\Reader $reader, - \Magento\Framework\App\Route\Config $config, - \Magento\Framework\App\AreaList $areaList, - \Magento\Framework\App\Route\Config\Reader $configReader + Reader $reader, + Config $config, + AreaList $areaList, + Config\Reader $configReader ) { $this->reader = $reader; $this->config = $config; @@ -89,6 +90,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $actionPaths = $this->reader->getActionFiles(); foreach ($actionPaths as $fullActionPath) { + /** + * Filter abstract classes and non action classes + * @link https://github.com/netz98/n98-magerun2/issues/1304 + */ + if (!is_a($fullActionPath, ActionInterface::class, true)) { + continue; + } + $area = 'frontend'; $actionPath = explode('\\', $fullActionPath);