12 use Symfony\Component\Console\Command\Command;
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
37 private $inputValidator;
42 private $consoleLoggerFactory;
55 private $objectManager;
76 $this->inputValidator = $inputValidator;
77 $this->consoleLoggerFactory = $consoleLoggerFactory;
79 $this->objectManager = $objectManagerProvider->
get();
81 parent::__construct();
91 $this->setName(
'setup:static-content:deploy')
92 ->setDescription(
'Deploys static view files')
93 ->setDefinition($this->options->getOptionsList());
103 protected function execute(InputInterface $input, OutputInterface
$output)
105 $time = microtime(
true);
107 if (!$input->getOption(Options::FORCE_RUN) && $this->getAppState()->getMode() !== State::MODE_PRODUCTION) {
110 'NOTE: Manual static content deployment is not required in "default" and "developer" modes.' 111 . PHP_EOL .
'In "default" and "developer" modes static contents are being deployed ' 112 .
'automatically on demand.' 113 . PHP_EOL .
'If you still want to deploy in these modes, use -f option: ' 114 .
"'bin/magento setup:static-content:deploy -f'" 119 $this->inputValidator->validate($input);
121 $options = $input->getOptions();
122 $options[Options::LANGUAGE] = $input->getArgument(Options::LANGUAGES_ARGUMENT) ?: [
'all'];
123 $refreshOnly = isset($options[Options::REFRESH_CONTENT_VERSION_ONLY])
124 && $options[Options::REFRESH_CONTENT_VERSION_ONLY];
126 $verbose =
$output->getVerbosity() > 1 ?
$output->getVerbosity() : OutputInterface::VERBOSITY_VERBOSE;
128 $logger = $this->consoleLoggerFactory->getLogger(
$output, $verbose);
130 $logger->notice(PHP_EOL .
"Deploy using {$options[Options::STRATEGY]} strategy");
136 $deployService = $this->objectManager->create(DeployStaticContent::class, [
140 $deployService->deploy($options);
143 $logger->notice(PHP_EOL .
"Execution time: " . (microtime(
true) - $time));
146 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
154 private function mockCache()
156 $this->objectManager->configure([
158 Cache::class => DummyCache::class
166 private function getAppState()
168 if (
null === $this->appState) {
169 $this->appState = $this->objectManager->get(State::class);
171 return $this->appState;
__construct(InputValidator $inputValidator, ConsoleLoggerFactory $consoleLoggerFactory, Options $options, ObjectManagerProvider $objectManagerProvider)
const DEFAULT_LANGUAGE_VALUE