0 follower

Final Class Yiisoft\TranslatorExtractor\Command\ExtractCommand

InheritanceYiisoft\TranslatorExtractor\Command\ExtractCommand » Symfony\Component\Console\Command\Command

Console command that allows extracting translator IDs from files.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\TranslatorExtractor\Extractor $extractor )
$extractor Yiisoft\TranslatorExtractor\Extractor

                public function __construct(private Extractor $extractor)
{
    parent::__construct();
}

            
configure() protected method

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.');
}

            
execute() protected method

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;
}