objectManager = $objectManagerProvider->get(); parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this->addArgument( self::INPUT_KEY_MODULES, InputArgument::IS_ARRAY | ($this->isModuleRequired() ? InputArgument::REQUIRED : InputArgument::OPTIONAL), 'Name of the module' ); $this->addOption( self::INPUT_KEY_CLEAR_STATIC_CONTENT, 'c', InputOption::VALUE_NONE, 'Clear generated static view files. Necessary, if the module(s) have static view files' ); parent::configure(); } /** * Returns if module argument is required * * @return bool */ abstract protected function isModuleRequired(); /** * Cleanup after updated modules status * * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function cleanup(InputInterface $input, OutputInterface $output) { /** @var \Magento\Framework\App\Cache $cache */ $cache = $this->objectManager->get(\Magento\Framework\App\Cache::class); $cache->clean(); $output->writeln('Cache cleared successfully.'); /** @var \Magento\Framework\App\State\CleanupFiles $cleanupFiles */ $cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class); $cleanupFiles->clearCodeGeneratedClasses(); $output->writeln( "Generated classes cleared successfully. Please run the 'setup:di:compile' command to " . 'generate classes.' ); if ($input->getOption(self::INPUT_KEY_CLEAR_STATIC_CONTENT)) { $cleanupFiles->clearMaterializedViewFiles(); $output->writeln('Generated static view files cleared successfully.'); } else { $output->writeln( "Info: Some modules might require static view files to be cleared. To do this, run '" . $this->getName() . "' with the --" . self::INPUT_KEY_CLEAR_STATIC_CONTENT . ' option to clear them.' ); } } }