Revert "[TASK] Deprecate @cli annotation"
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Command / ExtensionCommandController.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Command;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
18 use TYPO3\CMS\Core\Core\Environment;
19 use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
20
21 /**
22 * CommandController for working with extension management through CLI/scheduler
23 */
24 class ExtensionCommandController extends CommandController
25 {
26 /**
27 * @var bool
28 */
29 protected $requestAdminPermissions = true;
30
31 /**
32 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
33 */
34 protected $signalSlotDispatcher;
35
36 /**
37 * @param \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher
38 */
39 public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
40 {
41 $this->signalSlotDispatcher = $signalSlotDispatcher;
42 }
43
44 /**
45 * Installs an extension by key
46 *
47 * The extension files must be present in one of the
48 * recognised extension folder paths in TYPO3.
49 *
50 * @param string $extensionKey
51 * @cli
52 */
53 public function installCommand($extensionKey)
54 {
55 $this->emitPackagesMayHaveChangedSignal();
56
57 /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
58 $service = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class);
59 $service->install($extensionKey);
60 }
61
62 /**
63 * Uninstalls an extension by key
64 *
65 * The extension files must be present in one of the
66 * recognised extension folder paths in TYPO3.
67 *
68 * @param string $extensionKey
69 * @cli
70 */
71 public function uninstallCommand($extensionKey)
72 {
73 /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
74 $service = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class);
75 $service->uninstall($extensionKey);
76 }
77
78 /**
79 * Updates class loading information.
80 *
81 * This command is only needed during development. The extension manager takes care
82 * creating or updating this info properly during extension (de-)activation.
83 *
84 * @cli
85 */
86 public function dumpClassLoadingInformationCommand()
87 {
88 if (Environment::isComposerMode()) {
89 $this->output->outputLine('<error>Class loading information is managed by composer. Use "composer dump-autoload" command to update the information.</error>');
90 $this->quit(1);
91 } else {
92 ClassLoadingInformation::dumpClassLoadingInformation();
93 $this->output->outputLine('Class Loading information has been updated.');
94 }
95 }
96
97 /**
98 * Emits packages may have changed signal
99 */
100 protected function emitPackagesMayHaveChangedSignal()
101 {
102 $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
103 }
104 }