72dbf9a163310fbcd028a9549edc1419c2da9a86
[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 */
52 public function installCommand($extensionKey)
53 {
54 $this->emitPackagesMayHaveChangedSignal();
55
56 /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
57 $service = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class);
58 $service->install($extensionKey);
59 }
60
61 /**
62 * Uninstalls an extension by key
63 *
64 * The extension files must be present in one of the
65 * recognised extension folder paths in TYPO3.
66 *
67 * @param string $extensionKey
68 */
69 public function uninstallCommand($extensionKey)
70 {
71 /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
72 $service = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class);
73 $service->uninstall($extensionKey);
74 }
75
76 /**
77 * Updates class loading information.
78 *
79 * This command is only needed during development. The extension manager takes care
80 * creating or updating this info properly during extension (de-)activation.
81 */
82 public function dumpClassLoadingInformationCommand()
83 {
84 if (Environment::isComposerMode()) {
85 $this->output->outputLine('<error>Class loading information is managed by composer. Use "composer dump-autoload" command to update the information.</error>');
86 $this->quit(1);
87 } else {
88 ClassLoadingInformation::dumpClassLoadingInformation();
89 $this->output->outputLine('Class Loading information has been updated.');
90 }
91 }
92
93 /**
94 * Emits packages may have changed signal
95 */
96 protected function emitPackagesMayHaveChangedSignal()
97 {
98 $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
99 }
100 }