Completed
Push — master ( 471d20...bd01a5 )
by
unknown
16:06 queued 43s
created

DeactivateExtensionCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Extensionmanager\Command;
19
20
use Symfony\Component\Console\Command\Command;
21
use Symfony\Component\Console\Input\InputArgument;
22
use Symfony\Component\Console\Input\InputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
use Symfony\Component\Console\Style\SymfonyStyle;
25
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
26
27
/**
28
 * Command for deactivating an extension via CLI.
29
 */
30
class DeactivateExtensionCommand extends Command
31
{
32
    /**
33
     * @var EventDispatcherInterface
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extensionmanag...ventDispatcherInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
     */
35
    private $eventDispatcher;
0 ignored issues
show
introduced by
The private property $eventDispatcher is not used, and could be removed.
Loading history...
36
37
    /**
38
     * @var InstallUtility
39
     */
40
    private $installUtility;
41
42
    public function __construct(InstallUtility $installUtility)
43
    {
44
        $this->installUtility = $installUtility;
45
        parent::__construct();
46
    }
47
48
    /**
49
     * Defines the allowed options for this command
50
     */
51
    protected function configure()
52
    {
53
        $this
54
            ->setDescription('Deactivates an extension by extension key')
55
            ->setAliases(['extensionmanager:extension:uninstall', 'extension:uninstall'])
56
            ->addArgument(
57
                'extensionkey',
58
                InputArgument::REQUIRED,
59
                'The extension key of a currently activated extension.'
60
            );
61
    }
62
63
    /**
64
     * Installs an extension
65
     *
66
     * @inheritdoc
67
     */
68
    protected function execute(InputInterface $input, OutputInterface $output)
69
    {
70
        $io = new SymfonyStyle($input, $output);
71
        $extensionKey = $input->getArgument('extensionkey');
72
73
        $this->installUtility->uninstall($extensionKey);
0 ignored issues
show
Bug introduced by
It seems like $extensionKey can also be of type string[]; however, parameter $extensionKey of TYPO3\CMS\Extensionmanag...allUtility::uninstall() 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 ignore-type  annotation

73
        $this->installUtility->uninstall(/** @scrutinizer ignore-type */ $extensionKey);
Loading history...
74
75
        $io->success('Deactivated extension "' . $extensionKey . '" successfully.');
0 ignored issues
show
Bug introduced by
Are you sure $extensionKey of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
        $io->success('Deactivated extension "' . /** @scrutinizer ignore-type */ $extensionKey . '" successfully.');
Loading history...
76
        return 0;
77
    }
78
}
79