installerFactory = $installerFactory; $this->objectManagerProvider = $objectManagerProvider; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $options = [ new InputOption( self::INPUT_KEY_KEEP_GENERATED, null, InputOption::VALUE_NONE, 'Prevents generated files from being deleted. ' . PHP_EOL . 'We discourage using this option except when deploying to production. ' . PHP_EOL . 'Consult your system integrator or administrator for more information.' ) ]; $this->setName('setup:upgrade') ->setDescription('Upgrades the Magento application, DB data, and schema') ->setDefinition($options); parent::configure(); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $areaCode = 'setup'; /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ $objectManager = $this->objectManagerProvider->get(); /** @var \Magento\Framework\App\State $appState */ $appState = $objectManager->get('Magento\Framework\App\State'); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ $configLoader = $objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); $objectManager->configure($configLoader->load($areaCode)); $keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED); $installer = $this->installerFactory->create(new ConsoleLogger($output)); $installer->updateModulesSequence($keepGenerated); $installer->installSchema(); $installer->installDataFixtures(); if (!$keepGenerated) { $output->writeln('Please re-run Magento compile command'); } return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } }