|
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\Install; |
|
19
|
|
|
|
|
20
|
|
|
use Psr\Container\ContainerInterface; |
|
21
|
|
|
use TYPO3\CMS\Core\Configuration\ConfigurationManager; |
|
22
|
|
|
use TYPO3\CMS\Core\Console\CommandRegistry; |
|
23
|
|
|
use TYPO3\CMS\Core\Context\Context; |
|
24
|
|
|
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory; |
|
25
|
|
|
use TYPO3\CMS\Core\DependencyInjection\ContainerBuilder; |
|
26
|
|
|
use TYPO3\CMS\Core\Http\MiddlewareDispatcher; |
|
27
|
|
|
use TYPO3\CMS\Core\Middleware\NormalizedParamsAttribute as NormalizedParamsMiddleware; |
|
28
|
|
|
use TYPO3\CMS\Core\Package\AbstractServiceProvider; |
|
29
|
|
|
use TYPO3\CMS\Core\Package\PackageManager; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @internal |
|
33
|
|
|
*/ |
|
34
|
|
|
class ServiceProvider extends AbstractServiceProvider |
|
35
|
|
|
{ |
|
36
|
|
|
protected static function getPackagePath(): string |
|
37
|
|
|
{ |
|
38
|
|
|
return __DIR__ . '/../'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getFactories(): array |
|
42
|
|
|
{ |
|
43
|
|
|
return [ |
|
44
|
|
|
Http\Application::class => [ static::class, 'getApplication' ], |
|
45
|
|
|
Http\NotFoundRequestHandler::class => [ static::class, 'getNotFoundRequestHandler' ], |
|
46
|
|
|
Service\LateBootService::class => [ static::class, 'getLateBootService' ], |
|
47
|
|
|
Service\ClearCacheService::class => [ static::class, 'getClearCacheService' ], |
|
48
|
|
|
Service\LoadTcaService::class => [ static::class, 'getLoadTcaService' ], |
|
49
|
|
|
Middleware\Maintenance::class => [ static::class, 'getMaintenanceMiddleware' ], |
|
50
|
|
|
Controller\EnvironmentController::class => [ static::class, 'getEnvironmentController' ], |
|
51
|
|
|
Controller\UpgradeController::class => [ static::class, 'getUpgradeController' ], |
|
52
|
|
|
Command\LanguagePackCommand::class => [ static::class, 'getLanguagePackCommand' ], |
|
53
|
|
|
Command\UpgradeWizardRunCommand::class => [ static::class, 'getUpgradeWizardRunCommand' ], |
|
54
|
|
|
Command\UpgradeWizardListCommand::class => [ static::class, 'getUpgradeWizardListCommand' ], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getExtensions(): array |
|
59
|
|
|
{ |
|
60
|
|
|
return [ |
|
61
|
|
|
CommandRegistry::class => [ static::class, 'configureCommands' ], |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public static function getApplication(ContainerInterface $container): Http\Application |
|
66
|
|
|
{ |
|
67
|
|
|
$requestHandler = $container->get(Http\NotFoundRequestHandler::class); |
|
68
|
|
|
$dispatcher = new MiddlewareDispatcher($requestHandler, [], $container); |
|
69
|
|
|
|
|
70
|
|
|
// Stack of middlewares, executed LIFO |
|
71
|
|
|
$dispatcher->lazy(Middleware\Installer::class); |
|
72
|
|
|
$dispatcher->add($container->get(Middleware\Maintenance::class)); |
|
73
|
|
|
$dispatcher->lazy(NormalizedParamsMiddleware::class); |
|
74
|
|
|
|
|
75
|
|
|
return new Http\Application($dispatcher, $container->get(Context::class)); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public static function getNotFoundRequestHandler(ContainerInterface $container): Http\NotFoundRequestHandler |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
return new Http\NotFoundRequestHandler(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public static function getLateBootService(ContainerInterface $container): Service\LateBootService |
|
84
|
|
|
{ |
|
85
|
|
|
return new Service\LateBootService( |
|
86
|
|
|
$container->get(ContainerBuilder::class), |
|
87
|
|
|
$container |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public static function getClearCacheService(ContainerInterface $container): Service\ClearCacheService |
|
92
|
|
|
{ |
|
93
|
|
|
return new Service\ClearCacheService($container->get(Service\LateBootService::class)); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public static function getLoadTcaService(ContainerInterface $container): Service\LoadTcaService |
|
97
|
|
|
{ |
|
98
|
|
|
return new Service\LoadTcaService($container->get(Service\LateBootService::class)); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public static function getMaintenanceMiddleware(ContainerInterface $container): Middleware\Maintenance |
|
102
|
|
|
{ |
|
103
|
|
|
return new Middleware\Maintenance( |
|
104
|
|
|
$container->get(PackageManager::class), |
|
105
|
|
|
$container->get(ConfigurationManager::class), |
|
106
|
|
|
$container->get(PasswordHashFactory::class), |
|
107
|
|
|
$container |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public static function getEnvironmentController(ContainerInterface $container): Controller\EnvironmentController |
|
112
|
|
|
{ |
|
113
|
|
|
return new Controller\EnvironmentController( |
|
114
|
|
|
$container->get(Service\LateBootService::class) |
|
115
|
|
|
); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public static function getUpgradeController(ContainerInterface $container): Controller\UpgradeController |
|
119
|
|
|
{ |
|
120
|
|
|
return new Controller\UpgradeController( |
|
121
|
|
|
$container->get(PackageManager::class), |
|
122
|
|
|
$container->get(Service\LateBootService::class) |
|
123
|
|
|
); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public static function getLanguagePackCommand(ContainerInterface $container): Command\LanguagePackCommand |
|
|
|
|
|
|
127
|
|
|
{ |
|
128
|
|
|
return new Command\LanguagePackCommand('language:update'); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public static function getUpgradeWizardRunCommand(ContainerInterface $container): Command\UpgradeWizardRunCommand |
|
|
|
|
|
|
132
|
|
|
{ |
|
133
|
|
|
return new Command\UpgradeWizardRunCommand('upgrade:run'); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public static function getUpgradeWizardListCommand(ContainerInterface $container): Command\UpgradeWizardListCommand |
|
|
|
|
|
|
137
|
|
|
{ |
|
138
|
|
|
return new Command\UpgradeWizardListCommand('upgrade:list'); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public static function configureCommands(ContainerInterface $container, CommandRegistry $commandRegistry): CommandRegistry |
|
142
|
|
|
{ |
|
143
|
|
|
$commandRegistry->addLazyCommand('language:update', Command\LanguagePackCommand::class); |
|
144
|
|
|
$commandRegistry->addLazyCommand('upgrade:run', Command\UpgradeWizardRunCommand::class); |
|
145
|
|
|
$commandRegistry->addLazyCommand('upgrade:list', Command\UpgradeWizardListCommand::class); |
|
146
|
|
|
return $commandRegistry; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.