|
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
|
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Extensionmanager\Command; |
|
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; |
|
26
|
|
|
use TYPO3\CMS\Core\Core\Bootstrap; |
|
27
|
|
|
use TYPO3\CMS\Core\Package\Event\PackagesMayHaveChangedEvent; |
|
28
|
|
|
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Command for activating an existing extension via CLI. |
|
32
|
|
|
*/ |
|
33
|
|
|
class ActivateExtensionCommand extends Command |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var EventDispatcherInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $eventDispatcher; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var InstallUtility |
|
42
|
|
|
*/ |
|
43
|
|
|
private $installUtility; |
|
44
|
|
|
|
|
45
|
|
|
public function __construct( |
|
46
|
|
|
EventDispatcherInterface $eventDispatcher, |
|
47
|
|
|
InstallUtility $installUtility |
|
48
|
|
|
) { |
|
49
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
50
|
|
|
$this->installUtility = $installUtility; |
|
51
|
|
|
parent::__construct(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Defines the allowed options for this command |
|
56
|
|
|
*/ |
|
57
|
|
|
protected function configure() |
|
58
|
|
|
{ |
|
59
|
|
|
$this |
|
60
|
|
|
->setDescription('Activates an extension by key') |
|
61
|
|
|
->setHelp('The extension files must be present in one of the recognized extension folder paths in TYPO3.') |
|
62
|
|
|
->setAliases(['extensionmanager:extension:install', 'extension:install']) |
|
63
|
|
|
->addArgument( |
|
64
|
|
|
'extensionkey', |
|
65
|
|
|
InputArgument::REQUIRED, |
|
66
|
|
|
'The extension key of a currently deactivated extension, located in one of TYPO3\'s extension paths.' |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Installs an extension |
|
72
|
|
|
* |
|
73
|
|
|
* @inheritdoc |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
76
|
|
|
{ |
|
77
|
|
|
$io = new SymfonyStyle($input, $output); |
|
78
|
|
|
$extensionKey = $input->getArgument('extensionkey'); |
|
79
|
|
|
|
|
80
|
|
|
// Ensure the _cli_ user is authenticated because the extension might import data |
|
81
|
|
|
Bootstrap::initializeBackendAuthentication(); |
|
82
|
|
|
|
|
83
|
|
|
// Emits packages may have changed signal |
|
84
|
|
|
$this->eventDispatcher->dispatch(new PackagesMayHaveChangedEvent()); |
|
85
|
|
|
|
|
86
|
|
|
// Do the installation process |
|
87
|
|
|
$this->installUtility->install($extensionKey); |
|
88
|
|
|
|
|
89
|
|
|
$io->success('Activated extension ' . $extensionKey . ' successfully.'); |
|
|
|
|
|
|
90
|
|
|
return 0; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|