1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\TranslatorBundle\Command; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\TranslatorBundle\Repository\TranslationRepository; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Command to reset/request translation flags from the stash |
13
|
|
|
* |
14
|
|
|
* @final since 5.1 |
15
|
|
|
* NEXT_MAJOR extend from `Command` and remove `$this->getContainer` usages |
16
|
|
|
*/ |
17
|
|
|
class TranslationFlagCommand extends ContainerAwareCommand |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var TranslationRepository |
21
|
|
|
*/ |
22
|
|
|
private $translationRepository; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param TranslationRepository|null $translationRepository |
26
|
|
|
*/ |
27
|
|
|
public function __construct(/* TranslationRepository */ $translationRepository = null) |
28
|
|
|
{ |
29
|
|
|
parent::__construct(); |
30
|
|
|
|
31
|
|
|
if (!$translationRepository instanceof TranslationRepository) { |
32
|
|
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version symfony 3.4 and will be removed in symfony 4.0. If the command was registered by convention, make it a service instead. ', __METHOD__), E_USER_DEPRECATED); |
33
|
|
|
|
34
|
|
|
$this->setName(null === $translationRepository ? 'kuma:translator:flag' : $translationRepository); |
35
|
|
|
|
36
|
|
|
return; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$this->translationRepository = $translationRepository; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function configure() |
43
|
|
|
{ |
44
|
|
|
parent::configure(); |
45
|
|
|
|
46
|
|
|
$this |
47
|
|
|
->setName('kuma:translator:flag') |
48
|
|
|
->setDescription('Reset translation flags') |
49
|
|
|
->addOption('reset', 'r', InputOption::VALUE_NONE, 'Reset all flags to null in stash') |
50
|
|
|
; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
54
|
|
|
{ |
55
|
|
|
if ($input->getOption('reset')) { |
56
|
|
|
$this->resetAllTranslationFlags(); |
57
|
|
|
$output->writeln('<info>All translation and translation domain flags are reset.</info>'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return 0; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Rest all flags of all translations and all domains |
65
|
|
|
*/ |
66
|
|
|
public function resetAllTranslationFlags() |
67
|
|
|
{ |
68
|
|
|
if (null === $this->translationRepository) { |
69
|
|
|
$this->translationRepository = $this->getContainer()->get('kunstmaan_translator.repository.translation'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$this->translationRepository->resetAllFlags(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.