20 use Symfony\Component\Console;
45 private $serviceManager;
52 private $initException;
59 private $objectManager;
72 $this->serviceManager =
$application->getServiceManager();
74 $this->assertCompilerPreparation();
75 $this->initObjectManager();
76 }
catch (\Exception $exception) {
77 $output = new \Symfony\Component\Console\Output\ConsoleOutput();
79 '<error>' . $exception->getMessage() .
'</error>' 82 exit(static::RETURN_FAILURE);
89 $version = $productMetadata->getVersion();
100 public function doRun(Console\Input\InputInterface $input, Console\Output\OutputInterface
$output)
102 $exitCode = parent::doRun($input,
$output);
104 if ($this->initException) {
105 throw $this->initException;
116 return array_merge(parent::getDefaultCommands(), $this->getApplicationCommands());
124 protected function getApplicationCommands()
129 $setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
130 $commands = array_merge($commands, $setupCommandList->getCommands());
133 if ($this->objectManager->get(DeploymentConfig::class)->isAvailable()) {
135 $commandList = $this->objectManager->create(CommandListInterface::class);
136 $commands = array_merge($commands, $commandList->getCommands());
139 $commands = array_merge(
143 }
catch (\Exception $e) {
144 $this->initException = $e;
155 private function initObjectManager()
157 $params = (
new ComplexParameter(self::INPUT_KEY_BOOTSTRAP))->mergeFromArgv($_SERVER, $_SERVER);
160 $requestParams = $this->serviceManager->get(
'magento-init-params');
163 if (isset($requestParams[$appBootstrapKey]) && !isset(
$params[$appBootstrapKey])) {
164 $params[$appBootstrapKey] = $requestParams[$appBootstrapKey];
170 $omProvider = $this->serviceManager->get(ObjectManagerProvider::class);
171 $omProvider->setObjectManager($this->objectManager);
180 private function assertCompilerPreparation()
187 $compilerPreparation =
new CompilerPreparation(
188 $this->serviceManager,
189 new Console\Input\ArgvInput(),
193 $compilerPreparation->handleCompilerEnvironment();
209 $commands = array_merge(
211 $objectManager->create($commandListClass)->getCommands()
226 private function documentRootResolver(array
$config = []): array
static create($rootDir, array $initParams, ObjectManagerFactory $factory=null)
__construct($name='UNKNOWN', $version='UNKNOWN')
const INIT_PARAM_FILESYSTEM_DIR_PATHS
const PARAM_REQUIRE_MAINTENANCE
const CONFIG_PATH_DOCUMENT_ROOT_IS_PUB
const INPUT_KEY_BOOTSTRAP
getVendorCommands($objectManager)
doRun(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
if(!isset($_GET['name'])) $name