Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
I18nCollectPhrasesCommand.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Command\Command;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 
18 class I18nCollectPhrasesCommand extends Command
19 {
23  const INPUT_KEY_DIRECTORY = 'directory';
24  const INPUT_KEY_OUTPUT = 'output';
25  const SHORTCUT_KEY_OUTPUT = 'o';
26  const INPUT_KEY_MAGENTO = 'magento';
27  const SHORTCUT_KEY_MAGENTO = 'm';
33  protected function configure()
34  {
35  $this->setName('i18n:collect-phrases')
36  ->setDescription('Discovers phrases in the codebase');
37  $this->setDefinition([
38  new InputArgument(
39  self::INPUT_KEY_DIRECTORY,
40  InputArgument::OPTIONAL,
41  'Directory path to parse. Not needed if --magento flag is set'
42  ),
43  new InputOption(
44  self::INPUT_KEY_OUTPUT,
45  self::SHORTCUT_KEY_OUTPUT,
46  InputOption::VALUE_REQUIRED,
47  'Path (including filename) to an output file. With no file specified, defaults to stdout.'
48  ),
49  new InputOption(
50  self::INPUT_KEY_MAGENTO,
51  self::SHORTCUT_KEY_MAGENTO,
52  InputOption::VALUE_NONE,
53  'Use the --magento parameter to parse the current Magento codebase.' .
54  ' Omit the parameter if a directory is specified.'
55  ),
56  ]);
57  }
58 
62  protected function execute(InputInterface $input, OutputInterface $output)
63  {
64  $directory = $input->getArgument(self::INPUT_KEY_DIRECTORY);
65  if ($input->getOption(self::INPUT_KEY_MAGENTO)) {
66  $directory = BP;
67  if ($input->getArgument(self::INPUT_KEY_DIRECTORY)) {
68  throw new \InvalidArgumentException('Directory path is not needed when --magento flag is set.');
69  }
70  } elseif (!$input->getArgument(self::INPUT_KEY_DIRECTORY)) {
71  throw new \InvalidArgumentException('Directory path is needed when --magento flag is not set.');
72  }
73  $generator = ServiceLocator::getDictionaryGenerator();
74  $generator->generate(
75  $directory,
76  $input->getOption(self::INPUT_KEY_OUTPUT),
77  $input->getOption(self::INPUT_KEY_MAGENTO)
78  );
79  $output->writeln('<info>Dictionary successfully processed.</info>');
80  return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
81  }
82 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
execute(InputInterface $input, OutputInterface $output)
const BP
Definition: autoload.php:14