‪TYPO3CMS  11.5
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;
30 
34 class ‪ActivateExtensionCommand extends Command
35 {
39  private ‪$eventDispatcher;
40 
45 
46  public function ‪__construct(
47  EventDispatcherInterface ‪$eventDispatcher,
49  ) {
50  $this->eventDispatcher = ‪$eventDispatcher;
51  $this->installUtility = ‪$installUtility;
52  parent::__construct();
53  }
54 
60  public function ‪isEnabled()
61  {
63  }
64 
68  protected function ‪configure()
69  {
70  $this
71  ->setDescription('Activates an extension by key')
72  ->setHelp('The extension files must be present in one of the recognized extension folder paths in TYPO3.')
73  ->setAliases(['extensionmanager:extension:install', 'extension:install'])
74  ->addArgument(
75  'extensionkey',
76  InputArgument::REQUIRED,
77  'The extension key of a currently deactivated extension, located in one of TYPO3\'s extension paths.'
78  );
79  }
80 
86  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
87  {
88  $io = new SymfonyStyle($input, ‪$output);
89  $extensionKey = $input->getArgument('extensionkey');
90 
91  // Ensure the _cli_ user is authenticated because the extension might import data
93 
94  // Emits packages may have changed signal
95  $this->eventDispatcher->dispatch(new PackagesMayHaveChangedEvent());
96 
97  // Do the installation process
98  $this->installUtility->install($extensionKey);
99 
100  $io->success('Activated extension ' . $extensionKey . ' successfully.');
101  return 0;
102  }
103 }
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\__construct
‪__construct(EventDispatcherInterface $eventDispatcher, InstallUtility $installUtility)
Definition: ActivateExtensionCommand.php:44
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\configure
‪configure()
Definition: ActivateExtensionCommand.php:66
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ActivateExtensionCommand.php:38
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand
Definition: ActivateExtensionCommand.php:35
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:588
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\isEnabled
‪isEnabled()
Definition: ActivateExtensionCommand.php:58
‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility
Definition: InstallUtility.php:56
‪TYPO3\CMS\Extensionmanager\Command
Definition: ActivateExtensionCommand.php:18
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:152
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: ActivateExtensionCommand.php:84
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Core\Package\Event\PackagesMayHaveChangedEvent
Definition: PackagesMayHaveChangedEvent.php:23
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\$installUtility
‪InstallUtility $installUtility
Definition: ActivateExtensionCommand.php:42