11 use Symfony\Component\Console\Command\Command;
13 use Symfony\Component\Console\Input\InputOption;
14 use Symfony\Component\Console\Input\InputArgument;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Output\OutputInterface;
58 private $assetPublisher;
63 private $assetRepository;
77 parent::__construct(
'dev:source-theme:deploy');
78 $this->validator = $validator;
79 $this->assetPublisher = $assetPublisher;
80 $this->assetRepository = $assetRepository;
89 $this->setDescription(
'Collects and publishes source files for theme.')
94 InputArgument::IS_ARRAY,
95 'Files to pre-process (file should be specified without extension)',
96 [
'css/styles-m',
'css/styles-l']
101 InputOption::VALUE_REQUIRED,
102 'Type of source files: [less]',
108 InputOption::VALUE_REQUIRED,
115 InputOption::VALUE_REQUIRED,
116 'Area: [frontend|adminhtml]',
122 InputOption::VALUE_REQUIRED,
123 'Theme: [Vendor/theme]',
137 $area = $input->getOption(self::AREA_OPTION);
138 $locale = $input->getOption(self::LOCALE_OPTION);
139 $theme = $input->getOption(self::THEME_OPTION);
140 $type = $input->getOption(self::TYPE_ARGUMENT);
142 $files = $input->getArgument(self::FILE_ARGUMENT);
144 if (!$this->validator->isValid($locale)) {
145 throw new \InvalidArgumentException(
146 $locale .
' argument has invalid value, please run info:language:list for list of available locales' 150 if (!preg_match(
'#^[\w\-]+\/[\w\-]+$#',
$theme)) {
151 throw new \InvalidArgumentException(
152 'Value "' .
$theme .
'" of the option "' . self::THEME_OPTION .
153 '" has invalid format. The format should be "Vendor/theme".' 158 '<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>',
166 foreach (
$files as $file) {
168 $asset = $this->assetRepository->createAsset(
178 $this->assetPublisher->publish($asset);
179 }
catch (\
Magento\Framework\View\Asset\
File\NotFoundException $e) {
180 throw new \InvalidArgumentException(
181 'Verify entered values of the argument and options. ' . $e->getMessage()
185 $output->writeln(
'<comment>-> ' . $asset->getFilePath() .
'</comment>');
188 $output->writeln(
'<info>Successfully processed.</info>');
__construct(Locale $validator, Publisher $assetPublisher, Repository $assetRepository)
execute(InputInterface $input, OutputInterface $output)
foreach($appDirs as $dir) $files