Final Class Yiisoft\TranslatorExtractor\Command\ExtractCommand
| Inheritance | Yiisoft\TranslatorExtractor\Command\ExtractCommand » Symfony\Component\Console\Command\Command |
|---|
Console command that allows extracting translator IDs from files.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\TranslatorExtractor\Command\ExtractCommand |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\TranslatorExtractor\Command\ExtractCommand | |
| execute() | Yiisoft\TranslatorExtractor\Command\ExtractCommand |
Method Details
| public mixed __construct ( Yiisoft\TranslatorExtractor\Extractor $extractor ) | ||
| $extractor | Yiisoft\TranslatorExtractor\Extractor | |
public function __construct(private Extractor $extractor)
{
parent::__construct();
}
| protected void configure ( ) |
protected function configure(): void
{
$this
->addOption('languages', 'L', InputOption::VALUE_OPTIONAL, 'Comma separated list of languages to write message sources for. By default it is `en`.', 'en')
->addOption('category', 'C', InputOption::VALUE_OPTIONAL, 'Default message category to use when category is not set.', $this->defaultCategory)
->addOption('except', 'E', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Exclude path from extracting.', [])
->addOption('only', 'O', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Use the only specified path for extracting.', [])
->addArgument('path', InputArgument::OPTIONAL, 'Path for extracting message IDs.')
->setHelp('This command Extracts translator IDs from files within a given path.');
}
| protected integer execute ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) | ||
| $input | \Symfony\Component\Console\Input\InputInterface | |
| $output | \Symfony\Component\Console\Output\OutputInterface | |
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string */
$path = $input->getArgument('path') ?? getcwd();
/** @var string */
$languages = $input->getOption('languages');
/** @var string */
$category = $input->getOption('category');
/** @var string[] */
$except = $input->getOption('except');
/** @var string[] */
$only = $input->getOption('only');
/** @var string[] */
$languagesList = explode(',', $languages);
$this->extractor->setExcept($except);
$this->extractor->setOnly($only);
$this->extractor->process($path, $category, $languagesList, $output);
return 0;
}
Signup or Login in order to comment.