|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Micro framework package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Stanislau Komar <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Micro\Plugin\Http; |
|
15
|
|
|
|
|
16
|
|
|
use Micro\Component\DependencyInjection\Container; |
|
17
|
|
|
use Micro\Framework\Kernel\KernelInterface; |
|
18
|
|
|
use Micro\Framework\Kernel\Plugin\ConfigurableInterface; |
|
19
|
|
|
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; |
|
20
|
|
|
use Micro\Framework\Kernel\Plugin\PluginConfigurationTrait; |
|
21
|
|
|
use Micro\Framework\Kernel\Plugin\PluginDependedInterface; |
|
22
|
|
|
use Micro\Plugin\Http\Business\Executor\RouteExecutorFactoryInterface; |
|
23
|
|
|
use Micro\Plugin\Http\Business\Executor\RouteMiddlewareExecutorFactory; |
|
|
|
|
|
|
24
|
|
|
use Micro\Plugin\Http\Business\Middleware\MiddlewareLocatorFactory; |
|
25
|
|
|
use Micro\Plugin\Http\Business\Middleware\MiddlewareLocatorFactoryInterface; |
|
26
|
|
|
use Micro\Plugin\Http\Configuration\HttpMiddlewarePluginConfigurationInterface; |
|
27
|
|
|
use Micro\Plugin\Http\Decorator\HttpMiddlewareDecorator; |
|
|
|
|
|
|
28
|
|
|
use Micro\Plugin\Http\Facade\HttpFacadeInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @author Stanislau Komar <[email protected]> |
|
32
|
|
|
* |
|
33
|
|
|
* @method HttpMiddlewarePluginConfigurationInterface configuration() |
|
34
|
|
|
*/ |
|
35
|
|
|
class HttpMiddlewarePlugin implements PluginDependedInterface, DependencyProviderInterface, ConfigurableInterface |
|
36
|
|
|
{ |
|
37
|
|
|
use PluginConfigurationTrait; |
|
38
|
|
|
|
|
39
|
|
|
private HttpFacadeInterface $decorated; |
|
40
|
|
|
|
|
41
|
|
|
private KernelInterface $kernel; |
|
42
|
|
|
|
|
43
|
1 |
|
public function provideDependencies(Container $container): void |
|
44
|
|
|
{ |
|
45
|
1 |
|
$container->decorate(HttpFacadeInterface::class, |
|
46
|
1 |
|
function (HttpFacadeInterface $decorated, KernelInterface $kernel) { // @phpstan-ignore-line |
|
47
|
1 |
|
$this->decorated = $decorated; |
|
48
|
1 |
|
$this->kernel = $kernel; |
|
49
|
|
|
|
|
50
|
1 |
|
return $this->createDecorator(); |
|
51
|
1 |
|
}, |
|
52
|
1 |
|
$this->configuration()->getDecorationPriority() |
|
53
|
1 |
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
protected function createDecorator(): HttpFacadeInterface |
|
57
|
|
|
{ |
|
58
|
1 |
|
return new HttpMiddlewareDecorator( |
|
59
|
1 |
|
$this->decorated, |
|
60
|
1 |
|
$this->createRouteExecutorFactory() |
|
61
|
1 |
|
); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
1 |
|
protected function createRouteExecutorFactory(): RouteExecutorFactoryInterface |
|
65
|
|
|
{ |
|
66
|
1 |
|
return new RouteMiddlewareExecutorFactory( |
|
67
|
1 |
|
$this->decorated, |
|
68
|
1 |
|
$this->createMiddlewareLocatorFactory() |
|
69
|
1 |
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
protected function createMiddlewareLocatorFactory(): MiddlewareLocatorFactoryInterface |
|
73
|
|
|
{ |
|
74
|
1 |
|
return new MiddlewareLocatorFactory($this->kernel); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function getDependedPlugins(): iterable |
|
78
|
|
|
{ |
|
79
|
1 |
|
return [ |
|
80
|
1 |
|
HttpCorePlugin::class, |
|
81
|
1 |
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths