1 | <?php |
||||||
2 | |||||||
3 | namespace Ae\FeatureBundle\Command; |
||||||
4 | |||||||
5 | use Ae\FeatureBundle\Entity\FeatureManager; |
||||||
6 | use Doctrine\ORM\EntityManager; |
||||||
7 | use Symfony\Component\Console\Command\Command; |
||||||
8 | use Symfony\Component\Console\Input\InputArgument; |
||||||
9 | use Symfony\Component\Console\Input\InputInterface; |
||||||
10 | use Symfony\Component\Console\Output\OutputInterface; |
||||||
11 | |||||||
12 | /** |
||||||
13 | * Command used to disable an existing feature. |
||||||
14 | * |
||||||
15 | * @author Emanuele Minotto <[email protected]> |
||||||
16 | */ |
||||||
17 | class DisableFeatureCommand extends Command |
||||||
18 | { |
||||||
19 | /** |
||||||
20 | * @var FeatureManager |
||||||
21 | */ |
||||||
22 | private $featureManager; |
||||||
23 | |||||||
24 | /** |
||||||
25 | * @var EntityManager |
||||||
26 | */ |
||||||
27 | private $entityManager; |
||||||
28 | |||||||
29 | 1 | public function __construct( |
|||||
30 | FeatureManager $featureManager, |
||||||
31 | EntityManager $entityManager |
||||||
32 | ) { |
||||||
33 | 1 | parent::__construct(); |
|||||
34 | |||||||
35 | 1 | $this->featureManager = $featureManager; |
|||||
36 | 1 | $this->entityManager = $entityManager; |
|||||
37 | 1 | } |
|||||
38 | |||||||
39 | /** |
||||||
40 | * {@inheritdoc} |
||||||
41 | */ |
||||||
42 | 1 | protected function configure() |
|||||
43 | { |
||||||
44 | $this |
||||||
45 | 1 | ->setName('features:disable') |
|||||
46 | 1 | ->setDescription('Disable an existing feature') |
|||||
47 | 1 | ->addArgument('parent', InputArgument::REQUIRED, 'Parent feature') |
|||||
48 | 1 | ->addArgument('name', InputArgument::REQUIRED, 'Feature name'); |
|||||
49 | 1 | } |
|||||
50 | |||||||
51 | /** |
||||||
52 | * {@inheritdoc} |
||||||
53 | */ |
||||||
54 | 1 | public function execute(InputInterface $input, OutputInterface $output) |
|||||
55 | { |
||||||
56 | 1 | $name = $input->getArgument('name'); |
|||||
57 | 1 | $parent = $input->getArgument('parent'); |
|||||
58 | |||||||
59 | 1 | $output->write(sprintf( |
|||||
60 | 1 | 'Disabling <info>%s</info>.<info>%s</info>... ', |
|||||
61 | 1 | $parent, |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
62 | 1 | $name |
|||||
63 | )); |
||||||
64 | |||||||
65 | 1 | $feature = $this->featureManager->find($name, $parent); |
|||||
0 ignored issues
–
show
It seems like
$name can also be of type string[] ; however, parameter $name of Ae\FeatureBundle\Entity\FeatureManager::find() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
$parent can also be of type string[] ; however, parameter $parent of Ae\FeatureBundle\Entity\FeatureManager::find() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
66 | |||||||
67 | 1 | $feature->setEnabled(false); |
|||||
68 | |||||||
69 | 1 | $this->entityManager->persist($feature); |
|||||
70 | 1 | $this->entityManager->flush(); |
|||||
71 | |||||||
72 | 1 | $this->featureManager->emptyCache($name, $parent); |
|||||
0 ignored issues
–
show
It seems like
$name can also be of type string[] ; however, parameter $name of Ae\FeatureBundle\Entity\...reManager::emptyCache() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
$parent can also be of type string[] ; however, parameter $parent of Ae\FeatureBundle\Entity\...reManager::emptyCache() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
73 | |||||||
74 | 1 | $output->writeln('OK'); |
|||||
75 | |||||||
76 | 1 | return 0; |
|||||
77 | } |
||||||
78 | } |
||||||
79 |