[TASK] Migrate extension commands to Symfony
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Command / DeactivateExtensionCommand.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Extensionmanager\Command;
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 use Symfony\Component\Console\Command\Command;
19 use Symfony\Component\Console\Input\InputArgument;
20 use Symfony\Component\Console\Input\InputInterface;
21 use Symfony\Component\Console\Output\OutputInterface;
22 use Symfony\Component\Console\Style\SymfonyStyle;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Extbase\Object\ObjectManager;
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 * Defines the allowed options for this command
34 */
35 protected function configure()
36 {
37 $this
38 ->setDescription('Deactivates an extension by extension key')
39 ->setAliases(['extensionmanager:extension:uninstall', 'extension:uninstall'])
40 ->addArgument(
41 'extensionkey',
42 InputArgument::REQUIRED,
43 'The extension key of a currently activated extension.'
44 );
45 }
46
47 /**
48 * Installs an extension
49 *
50 * @inheritdoc
51 */
52 protected function execute(InputInterface $input, OutputInterface $output)
53 {
54 $io = new SymfonyStyle($input, $output);
55 $extensionKey = $input->getArgument('extensionkey');
56
57 $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
58 $objectManager->get(InstallUtility::class)->uninstall($extensionKey);
59
60 $io->success('Deactivated extension "' . $extensionKey . '" successfully.');
61 }
62 }