‪TYPO3CMS  9.5
ActivateExtensionCommand.php
Go to the documentation of this file.
1 <?php
2 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 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;
28 
32 class ‪ActivateExtensionCommand extends Command
33 {
37  protected function ‪configure()
38  {
39  $this
40  ->setDescription('Activates an extension by key')
41  ->setHelp('The extension files must be present in one of the recognized extension folder paths in TYPO3.')
42  ->setAliases(['extensionmanager:extension:install', 'extension:install'])
43  ->addArgument(
44  'extensionkey',
45  InputArgument::REQUIRED,
46  'The extension key of a currently deactivated extension, located in one of TYPO3\'s extension paths.'
47  );
48  }
49 
55  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
56  {
57  $io = new SymfonyStyle($input, ‪$output);
58  $extensionKey = $input->getArgument('extensionkey');
59 
60  // Ensure the _cli_ user is authenticated because the extension might import data
62 
63  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
64  // Emits packages may have changed signal
65  ‪$signalSlotDispatcher = $objectManager->get(Dispatcher::class);
66  ‪$signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
67 
68  // Do the installation process
69  $objectManager->get(InstallUtility::class)->install($extensionKey);
70 
71  $io->success('Activated extension ' . $extensionKey . ' successfully.');
72  }
73 }
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\configure
‪configure()
Definition: ActivateExtensionCommand.php:37
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand
Definition: ActivateExtensionCommand.php:33
‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility
Definition: InstallUtility.php:32
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static Bootstrap null initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:974
‪TYPO3\CMS\Extensionmanager\Command
Definition: ActivateExtensionCommand.php:3
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: ActivateExtensionCommand.php:55
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪$signalSlotDispatcher
‪$signalSlotDispatcher
Definition: ext_localconf.php:6
‪TYPO3\CMS\Extbase\SignalSlot\Dispatcher
Definition: Dispatcher.php:28