‪TYPO3CMS  10.4
ActivateExtensionCommand.php
Go to the documentation of this file.
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 
19 
20 use Psr\EventDispatcher\EventDispatcherInterface;
21 use Symfony\Component\Console\Command\Command;
22 use Symfony\Component\Console\Input\InputArgument;
23 use Symfony\Component\Console\Input\InputInterface;
24 use Symfony\Component\Console\Output\OutputInterface;
25 use Symfony\Component\Console\Style\SymfonyStyle;
31 
35 class ‪ActivateExtensionCommand extends Command
36 {
40  protected function ‪configure()
41  {
42  $this
43  ->setDescription('Activates an extension by key')
44  ->setHelp('The extension files must be present in one of the recognized extension folder paths in TYPO3.')
45  ->setAliases(['extensionmanager:extension:install', 'extension:install'])
46  ->addArgument(
47  'extensionkey',
48  InputArgument::REQUIRED,
49  'The extension key of a currently deactivated extension, located in one of TYPO3\'s extension paths.'
50  );
51  }
52 
58  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
59  {
60  $io = new SymfonyStyle($input, ‪$output);
61  $extensionKey = $input->getArgument('extensionkey');
62 
63  // Ensure the _cli_ user is authenticated because the extension might import data
65 
66  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
67 
68  // Emits packages may have changed signal
69  GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(new ‪PackagesMayHaveChangedEvent());
70 
71  // Do the installation process
72  $objectManager->get(InstallUtility::class)->install($extensionKey);
73 
74  $io->success('Activated extension ' . $extensionKey . ' successfully.');
75  return 0;
76  }
77 }
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\configure
‪configure()
Definition: ActivateExtensionCommand.php:40
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand
Definition: ActivateExtensionCommand.php:36
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:607
‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility
Definition: InstallUtility.php:55
‪TYPO3\CMS\Extensionmanager\Command
Definition: ActivateExtensionCommand.php:18
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: ActivateExtensionCommand.php:58
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Package\Event\PackagesMayHaveChangedEvent
Definition: PackagesMayHaveChangedEvent.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28