/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php
114 строк
4 KB
Rajesh Kumar
Merge remote-tracking branch 'origin/2.4-develop' into AC-15170
05 дек 2025, 13:01
05 дек 2025, 13:01
e3f334a
Код
Авторство
О чём код?
<?php /** * Copyright 2015 Adobe * All Rights Reserved. */ namespace Magento\Setup\Console\Command; use Magento\Framework\App\Utility\Files; use Magento\Framework\Component\ComponentRegistrar; use Magento\Framework\Component\DirSearch; use Magento\Framework\Filesystem\Directory\ReadFactory; use Magento\Framework\ObjectManager\ObjectManager; use Magento\Framework\View\Design\Theme\ThemePackageList; use Magento\Setup\Model\ObjectManagerProvider; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Abstract class for dependency report commands */ abstract class AbstractDependenciesCommand extends Command { /** * Input key for directory option */ public const INPUT_KEY_DIRECTORY = 'directory'; /** * Input key for output path of report file */ public const INPUT_KEY_OUTPUT = 'output'; /** * * Magento object manager. * Responsible for creating and managing application objects * * @var ObjectManager */ private $objectManager; /** * Constructor * * @param ObjectManagerProvider $objectManagerProvider */ public function __construct(ObjectManagerProvider $objectManagerProvider) { $this->objectManager = $objectManagerProvider->get(); parent::__construct(); } /** * @inheritdoc */ protected function configure() { $this->setDefinition( [ new InputOption( self::INPUT_KEY_OUTPUT, 'o', InputOption::VALUE_REQUIRED, 'Report filename', $this->getDefaultOutputFilename() ) ] ); parent::configure(); } /** * Build dependencies report * * @param string $outputPath * @return void */ abstract protected function buildReport($outputPath); /** * Get the default output report filename * * @return string */ abstract protected function getDefaultOutputFilename(); /** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { try { /** @var \Magento\Framework\Component\ComponentRegistrar $componentRegistrar */ $componentRegistrar = $this->objectManager->get(\Magento\Framework\Component\ComponentRegistrar::class); /** @var \Magento\Framework\Component\DirSearch $dirSearch */ $dirSearch = $this->objectManager->get(\Magento\Framework\Component\DirSearch::class); /** @var \Magento\Framework\View\Design\Theme\ThemePackageList $themePackageList */ $themePackageList = $this->objectManager->get(\Magento\Framework\View\Design\Theme\ThemePackageList::class); Files::setInstance(new Files($componentRegistrar, $dirSearch, $themePackageList)); $this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT)); $output->writeln('<info>Report successfully processed.</info>'); } catch (\Exception $e) { $output->writeln( '<error>Please check the path you provided. Dependencies report generator failed with error: ' . $e->getMessage() . '</error>' ); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } }