1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EightPoints\Bundle\GuzzleBundle; |
4
|
|
|
|
5
|
|
|
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\EightPointsGuzzleExtension; |
6
|
|
|
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\Compiler\EventHandlerCompilerPass; |
|
|
|
|
7
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
8
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
10
|
|
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; |
11
|
|
|
|
12
|
|
|
class EightPointsGuzzleBundle extends Bundle |
13
|
|
|
{ |
14
|
|
|
/** @var \EightPoints\Bundle\GuzzleBundle\PluginInterface[] */ |
15
|
|
|
protected $plugins = []; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface[] $plugins |
19
|
|
|
*/ |
20
|
|
|
public function __construct(array $plugins = []) |
21
|
|
|
{ |
22
|
|
|
foreach ($plugins as $plugin) { |
23
|
|
|
$this->registerPlugin($plugin); |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Build EightPointsGuzzleBundle |
29
|
|
|
* |
30
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
|
|
public function build(ContainerBuilder $container) |
35
|
|
|
{ |
36
|
|
|
parent::build($container); |
37
|
|
|
|
38
|
|
|
foreach ($this->plugins as $plugin) { |
39
|
|
|
$plugin->build($container); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Overwrite getContainerExtension |
45
|
|
|
* - no naming convention of alias needed |
46
|
|
|
* - extension class can be moved easily now |
47
|
|
|
* |
48
|
|
|
* @return \Symfony\Component\DependencyInjection\Extension\ExtensionInterface The container extension |
49
|
|
|
*/ |
50
|
|
|
public function getContainerExtension() : ExtensionInterface |
51
|
|
|
{ |
52
|
|
|
if ($this->extension === null) { |
53
|
|
|
$this->extension = new EightPointsGuzzleExtension($this->plugins); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $this->extension; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdoc |
61
|
|
|
*/ |
62
|
|
|
public function boot() |
63
|
|
|
{ |
64
|
|
|
foreach ($this->plugins as $plugin) { |
65
|
|
|
$plugin->boot(); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface $plugin |
71
|
|
|
* |
72
|
|
|
* @throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
73
|
|
|
* |
74
|
|
|
* @return void |
75
|
|
|
*/ |
76
|
|
|
protected function registerPlugin(PluginInterface $plugin) : void |
77
|
|
|
{ |
78
|
|
|
// Check plugins name duplication |
79
|
|
|
foreach ($this->plugins as $registeredPlugin) { |
80
|
|
|
if ($registeredPlugin->getPluginName() === $plugin->getPluginName()) { |
81
|
|
|
throw new InvalidConfigurationException(sprintf( |
82
|
|
|
'Trying to connect two plugins with same name: %s', |
83
|
|
|
$plugin->getPluginName() |
84
|
|
|
)); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
$this->plugins[] = $plugin; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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