These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\SearchBundle\DependencyInjection; |
||
4 | |||
5 | use Symfony\Component\Config\FileLocator; |
||
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
7 | use Symfony\Component\DependencyInjection\Loader; |
||
8 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
||
9 | use Symfony\Component\Yaml\Yaml; |
||
10 | |||
11 | /** |
||
12 | * This is the class that loads and manages your bundle configuration |
||
13 | * |
||
14 | * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
||
15 | */ |
||
16 | class KunstmaanSearchExtension extends Extension |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | public function load(array $configs, ContainerBuilder $container) |
||
22 | { |
||
23 | $configuration = new Configuration(); |
||
24 | $config = $this->processConfiguration($configuration, $configs); |
||
25 | |||
26 | if (count($config['analyzer_languages']) <= 0) { |
||
27 | $config['analyzer_languages'] = $this->getDefaultAnalyzerLanguages(); |
||
28 | } |
||
29 | $container->setParameter('analyzer_languages', \array_change_key_case($config['analyzer_languages']), \CASE_LOWER); |
||
0 ignored issues
–
show
|
|||
30 | |||
31 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
32 | $loader->load('services.yml'); |
||
33 | |||
34 | $this->loadConnectionParameters($container, $config); |
||
35 | |||
36 | $this->addSearchIndexPrefixParameter($container, $config); |
||
37 | } |
||
38 | |||
39 | public function getDefaultAnalyzerLanguages() |
||
40 | { |
||
41 | return Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/analyzer_languages.yml')); |
||
42 | } |
||
43 | |||
44 | private function loadConnectionParameters(ContainerBuilder $container, array $config) |
||
45 | { |
||
46 | $this->addHostParameter($container, $config); |
||
47 | $this->addPortParameter($container, $config); |
||
48 | $this->addUserParameter($container, $config); |
||
49 | $this->addPasswordParameter($container, $config); |
||
50 | } |
||
51 | |||
52 | View Code Duplication | private function addHostParameter(ContainerBuilder $container, array $config) |
|
53 | { |
||
54 | $searchHost = $container->hasParameter('kunstmaan_search.hostname') ? $container->getParameter('kunstmaan_search.hostname') : 'localhost'; |
||
55 | if (null === $config['connection']['host'] && $searchHost !== 'localhost') { |
||
56 | @trigger_error('Not providing a value for the "kunstmaan_search.connection.host" config while setting the "kunstmaan_search.hostname" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "kunstmaan_search.hostname" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
57 | } |
||
58 | |||
59 | if (null !== $config['connection']['host']) { |
||
60 | $searchHost = $config['connection']['host']; |
||
61 | } |
||
62 | |||
63 | $container->setParameter('kunstmaan_search.hostname', $searchHost); |
||
64 | } |
||
65 | |||
66 | View Code Duplication | private function addPortParameter(ContainerBuilder $container, array $config) |
|
67 | { |
||
68 | $searchPort = $container->hasParameter('kunstmaan_search.port') ? $container->getParameter('kunstmaan_search.port') : 9200; |
||
69 | if (null === $config['connection']['port'] && $searchPort !== 9200) { |
||
70 | @trigger_error('Not providing a value for the "kunstmaan_search.connection.port" config while setting the "kunstmaan_search.port" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "kunstmaan_search.port" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
71 | } |
||
72 | |||
73 | if (null !== $config['connection']['port']) { |
||
74 | $searchPort = $config['connection']['port']; |
||
75 | } |
||
76 | |||
77 | $container->setParameter('kunstmaan_search.port', $searchPort); |
||
78 | } |
||
79 | |||
80 | View Code Duplication | private function addUserParameter(ContainerBuilder $container, array $config) |
|
81 | { |
||
82 | $searchUsername = $container->hasParameter('kunstmaan_search.username') ? $container->getParameter('kunstmaan_search.username') : null; |
||
83 | if (null === $config['connection']['username'] && null !== $searchUsername) { |
||
84 | @trigger_error('Not providing a value for the "kunstmaan_search.connection.username" config while setting the "kunstmaan_search.username" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "kunstmaan_search.username" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
85 | } |
||
86 | |||
87 | if (null !== $config['connection']['username']) { |
||
88 | $searchUsername = $config['connection']['username']; |
||
89 | } |
||
90 | |||
91 | $container->setParameter('kunstmaan_search.username', $searchUsername); |
||
92 | } |
||
93 | |||
94 | View Code Duplication | private function addPasswordParameter(ContainerBuilder $container, array $config) |
|
95 | { |
||
96 | $searchPassword = $container->hasParameter('kunstmaan_search.password') ? $container->getParameter('kunstmaan_search.password') : null; |
||
97 | if (null === $config['connection']['password'] && null !== $searchPassword) { |
||
98 | @trigger_error('Not providing a value for the "kunstmaan_search.connection.password" config while setting the "kunstmaan_search.password" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "kunstmaan_search.password" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
99 | } |
||
100 | |||
101 | if (null !== $config['connection']['password']) { |
||
102 | $searchPassword = $config['connection']['password']; |
||
103 | } |
||
104 | |||
105 | $container->setParameter('kunstmaan_search.password', $searchPassword); |
||
106 | } |
||
107 | |||
108 | View Code Duplication | private function addSearchIndexPrefixParameter(ContainerBuilder $container, array $config) |
|
109 | { |
||
110 | $indexPrefix = $container->hasParameter('searchindexprefix') ? $container->getParameter('searchindexprefix') : null; |
||
111 | if (null === $config['index_prefix'] && null !== $indexPrefix) { |
||
112 | @trigger_error('Not providing a value for the "kunstmaan_search.index_prefix" config while setting the "searchindexprefix" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "searchindexprefix" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
113 | } |
||
114 | |||
115 | if (null !== $config['index_prefix']) { |
||
116 | $indexPrefix = $config['index_prefix']; |
||
117 | } |
||
118 | |||
119 | $container->setParameter('kunstmaan_search.index_prefix', $indexPrefix); |
||
120 | } |
||
121 | } |
||
122 |
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.