1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MediaMonks\RestApiBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; |
8
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
9
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* This is the class that loads and manages your bundle configuration. |
13
|
|
|
* |
14
|
|
|
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html |
15
|
|
|
*/ |
16
|
|
|
class MediaMonksRestApiExtension extends Extension implements ExtensionInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
3 |
|
public function load(array $configs, ContainerBuilder $container) |
22
|
|
|
{ |
23
|
3 |
|
$config = $this->processConfiguration(new Configuration(), $configs); |
24
|
|
|
|
25
|
3 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
26
|
3 |
|
$loader->load('services.xml'); |
27
|
|
|
|
28
|
3 |
|
$container->getDefinition('mediamonks_rest_api.request_matcher') |
29
|
3 |
|
->replaceArgument(0, $config['request_matcher']['whitelist']); |
30
|
3 |
|
$container->getDefinition('mediamonks_rest_api.request_matcher') |
31
|
3 |
|
->replaceArgument(1, $config['request_matcher']['blacklist']); |
32
|
|
|
|
33
|
3 |
|
$container->getDefinition('mediamonks_rest_api.request_transformer') |
34
|
3 |
|
->replaceArgument(0, $config['output_formats']); |
35
|
|
|
|
36
|
3 |
|
$container->getDefinition('mediamonks_rest_api.response_transformer') |
37
|
3 |
|
->replaceArgument(2, [ |
38
|
3 |
|
'debug' => $this->getDebug($container, $config), |
|
|
|
|
39
|
3 |
|
'post_message_origin' => $config['post_message_origin'] |
40
|
3 |
|
]); |
41
|
3 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
3 |
|
public function getAlias() |
47
|
|
|
{ |
48
|
3 |
|
return 'mediamonks_rest_api'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param ContainerBuilder $container |
53
|
|
|
* @return bool |
54
|
|
|
*/ |
55
|
3 |
|
public function getDebug(ContainerBuilder $container) |
|
|
|
|
56
|
|
|
{ |
57
|
3 |
|
return true; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.