Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Translator / Cli / LanguageController.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Translator\Cli;
12
13 use Behat\Testwork\Cli\Controller;
14 use Symfony\Component\Console\Command\Command;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Input\InputOption;
17 use Symfony\Component\Console\Output\OutputInterface;
18 use Symfony\Component\Translation\Translator;
19
20 /**
21  * Configures translator service to use custom locale.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class LanguageController implements Controller
26 {
27     /**
28      * @var Translator
29      */
30     private $translator;
31
32     /**
33      * Initializes controller.
34      *
35      * @param Translator $translator
36      */
37     public function __construct(Translator $translator)
38     {
39         $this->translator = $translator;
40     }
41
42     /**
43      * {@inheritdoc}
44      */
45     public function configure(Command $command)
46     {
47         $command->addOption('--lang', null, InputOption::VALUE_REQUIRED,
48             'Print output in particular language.'
49         );
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     public function execute(InputInterface $input, OutputInterface $output)
56     {
57         if (!$input->getOption('lang')) {
58             return;
59         }
60
61         $this->translator->setLocale($input->getOption('lang'));
62     }
63 }