12 use Symfony\Component\Console\Command\Command;
13 use Symfony\Component\Console\Input\InputArgument;
14 use Symfony\Component\Console\Input\InputInterface;
15 use Symfony\Component\Console\Input\InputOption;
16 use Symfony\Component\Console\Output\OutputInterface;
38 private $objectManager;
48 parent::__construct();
58 $this->setName(
'deploy:mode:set')
63 InputArgument::REQUIRED,
64 'The application mode to set. Available options are "developer" or "production"' 67 self::SKIP_COMPILATION_OPTION,
69 InputOption::VALUE_NONE,
70 'Skips the clearing and regeneration of static content (generated code, preprocessed CSS, ' 71 .
'and assets in pub/static/)' 80 protected function execute(InputInterface $input, OutputInterface
$output)
84 $modeController = $this->objectManager->create(
85 \
Magento\Deploy\Model\Mode::class,
91 $toMode = $input->getArgument(self::MODE_ARGUMENT);
92 $skipCompilation = $input->getOption(self::SKIP_COMPILATION_OPTION);
95 $modeController->enableDeveloperMode();
98 if ($skipCompilation) {
99 $modeController->enableProductionModeMinimal();
101 $modeController->enableProductionMode();
105 $modeController->enableDefaultMode();
108 throw new LocalizedException(
__(
'The mode can\'t be switched to "%1".', $toMode));
110 $output->writeln(
'Enabled ' . $toMode .
' mode.');
112 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
113 }
catch (\Exception $e) {
114 $output->writeln(
'<error>' . $e->getMessage() .
'</error>');
115 if (
$output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
116 $output->writeln($e->getTraceAsString());
119 return \Magento\Framework\Console\Cli::RETURN_FAILURE;
const SKIP_COMPILATION_OPTION
__construct(ObjectManagerInterface $objectManager)