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\DashboardBundle\DependencyInjection; |
||
4 | |||
5 | use Symfony\Component\Config\FileLocator; |
||
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
7 | use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
||
8 | use Symfony\Component\DependencyInjection\Loader; |
||
9 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
||
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 KunstmaanDashboardExtension extends Extension implements PrependExtensionInterface |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | View Code Duplication | public function load(array $configs, ContainerBuilder $container) |
|
0 ignored issues
–
show
|
|||
22 | { |
||
23 | $configuration = new Configuration(); |
||
24 | $config = $this->processConfiguration($configuration, $configs); |
||
25 | |||
26 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
27 | $loader->load('services.yml'); |
||
28 | $loader->load('commands.yml'); |
||
29 | |||
30 | $this->loadGoogleAnalyticsParameters($container, $config); |
||
31 | } |
||
32 | |||
33 | public function prepend(ContainerBuilder $container) |
||
34 | { |
||
35 | $container->prependExtensionConfig('framework', ['esi' => ['enabled' => true]]); |
||
36 | } |
||
37 | |||
38 | private function loadGoogleAnalyticsParameters(ContainerBuilder $container, array $config) |
||
39 | { |
||
40 | $this->addApplicationNameParameter($container, $config); |
||
41 | $this->addClientIdParameter($container, $config); |
||
42 | $this->addClientSecretParameter($container, $config); |
||
43 | $this->addDeveloperKeyParameter($container, $config); |
||
44 | } |
||
45 | |||
46 | View Code Duplication | private function addClientIdParameter(ContainerBuilder $container, array $config) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
47 | { |
||
48 | $clientId = $container->hasParameter('google.api.client_id') ? $container->getParameter('google.api.client_id') : ''; |
||
49 | if (null === $config['google_analytics']['api']['client_id'] && $clientId !== '') { |
||
50 | @trigger_error('Not providing a value for the "kunstmaan_dashboard.google_analytics.api.client_id" config while setting the "google.api.client_id" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "google.api.client_id" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
51 | } |
||
52 | |||
53 | if (null !== $config['google_analytics']['api']['client_id']) { |
||
54 | $clientId = $config['google_analytics']['api']['client_id']; |
||
55 | } |
||
56 | |||
57 | $container->setParameter('kunstmaan_dashboard.google_analytics.api.client_id', $clientId); |
||
58 | } |
||
59 | |||
60 | View Code Duplication | private function addClientSecretParameter(ContainerBuilder $container, array $config) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
61 | { |
||
62 | $clientSecret = $container->hasParameter('google.api.client_secret') ? $container->getParameter('google.api.client_secret') : ''; |
||
63 | if (null === $config['google_analytics']['api']['client_secret'] && $clientSecret !== '') { |
||
64 | @trigger_error('Not providing a value for the "kunstmaan_dashboard.google_analytics.api.client_secret" config while setting the "google.api.client_secret" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "google.api.client_secret" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
65 | } |
||
66 | |||
67 | if (null !== $config['google_analytics']['api']['client_secret']) { |
||
68 | $clientSecret = $config['google_analytics']['api']['client_secret']; |
||
69 | } |
||
70 | |||
71 | $container->setParameter('kunstmaan_dashboard.google_analytics.api.client_secret', $clientSecret); |
||
72 | } |
||
73 | |||
74 | View Code Duplication | private function addDeveloperKeyParameter(ContainerBuilder $container, array $config) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
75 | { |
||
76 | $devKey = $container->hasParameter('google.api.dev_key') ? $container->getParameter('google.api.dev_key') : ''; |
||
77 | if (null === $config['google_analytics']['api']['dev_key'] && $devKey !== '') { |
||
78 | @trigger_error('Not providing a value for the "kunstmaan_dashboard.google_analytics.api.dev_key" config while setting the "google.api.dev_key" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "google.api.dev_key" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
79 | } |
||
80 | |||
81 | if (null !== $config['google_analytics']['api']['dev_key']) { |
||
82 | $devKey = $config['google_analytics']['api']['dev_key']; |
||
83 | } |
||
84 | |||
85 | $container->setParameter('kunstmaan_dashboard.google_analytics.api.dev_key', $devKey); |
||
86 | } |
||
87 | |||
88 | View Code Duplication | private function addApplicationNameParameter(ContainerBuilder $container, array $config) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
89 | { |
||
90 | $appName = $container->hasParameter('google.api.app_name') ? $container->getParameter('google.api.app_name') : 'Kuma Analytics Dashboard'; |
||
91 | if (null === $config['google_analytics']['api']['app_name'] && $appName !== '' && $appName !== 'Kuma Analytics Dashboard') { |
||
92 | @trigger_error('Not providing a value for the "kunstmaan_dashboard.google_analytics.api.app_name" config while setting the "google.api.app_name" parameter is deprecated since KunstmaanDashboardBundle 5.2, this config value will replace the "google.api.app_name" parameter in KunstmaanDashboardBundle 6.0.', E_USER_DEPRECATED); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
93 | } |
||
94 | |||
95 | if (null !== $config['google_analytics']['api']['app_name']) { |
||
96 | $appName = $config['google_analytics']['api']['app_name']; |
||
97 | } |
||
98 | |||
99 | $container->setParameter('kunstmaan_dashboard.google_analytics.api.app_name', $appName); |
||
100 | } |
||
101 | } |
||
102 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.