‪TYPO3CMS  ‪main
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 {
36  public function ‪__construct(
37  private readonly EventDispatcherInterface $eventDispatcher,
38  private readonly ‪InstallUtility $installUtility
39  ) {
40  parent::__construct();
41  }
42 
46  public function ‪isEnabled(): bool
47  {
49  }
50 
54  protected function ‪configure()
55  {
56  $this
57  ->setDescription('Activates an extension by key')
58  ->setHelp('The extension files must be present in one of the recognized extension folder paths in TYPO3.')
59  ->setAliases(['extensionmanager:extension:install', 'extension:install'])
60  ->addArgument(
61  'extensionkey',
62  InputArgument::REQUIRED,
63  'The extension key of a currently deactivated extension, located in one of TYPO3\'s extension paths.'
64  );
65  }
66 
70  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
71  {
72  $io = new SymfonyStyle($input, ‪$output);
73  $extensionKey = $input->getArgument('extensionkey');
74 
75  // Ensure the _cli_ user is authenticated because the extension might import data
77 
78  // Emits packages may have changed signal
79  $this->eventDispatcher->dispatch(new ‪PackagesMayHaveChangedEvent());
80 
81  // Do the installation process
82  $this->installUtility->install($extensionKey);
83 
84  $io->success('Activated extension ' . $extensionKey . ' successfully.');
85  return Command::SUCCESS;
86  }
87 }
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\__construct
‪__construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly InstallUtility $installUtility)
Definition: ActivateExtensionCommand.php:36
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\configure
‪configure()
Definition: ActivateExtensionCommand.php:54
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static isComposerMode()
Definition: Environment.php:137
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand
Definition: ActivateExtensionCommand.php:35
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\isEnabled
‪isEnabled()
Definition: ActivateExtensionCommand.php:46
‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility
Definition: InstallUtility.php:40
‪TYPO3\CMS\Extensionmanager\Command
Definition: ActivateExtensionCommand.php:18
‪$output
‪$output
Definition: annotationChecker.php:114
‪TYPO3\CMS\Extensionmanager\Command\ActivateExtensionCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: ActivateExtensionCommand.php:70
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:62
‪TYPO3\CMS\Core\Package\Event\PackagesMayHaveChangedEvent
Definition: PackagesMayHaveChangedEvent.php:23
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static initializeBackendAuthentication()
Definition: Bootstrap.php:527