Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

Compiler/DomainConfigurationPass.php (2 issues)

Upgrade to new PHP Analysis Engine

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\AdminBundle\DependencyInjection\Compiler;
4
5
use Kunstmaan\AdminBundle\Helper\DomainConfiguration;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10 View Code Duplication
class DomainConfigurationPass implements CompilerPassInterface
0 ignored issues
show
This class 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.

Loading history...
11
{
12 3
    public function process(ContainerBuilder $container)
13
    {
14 3
        if ($container->hasParameter('kunstmaan_admin.domain_configuration.class') && $container->getParameter('kunstmaan_admin.domain_configuration.class') !== DomainConfiguration::class) {
15
            @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
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.');
}
Loading history...
16
                'Overriding the domain configuration class by setting the "kunstmaan_admin.domain_configuration.class" parameter is deprecated since KunstmaanAdminDomainBundle 5.1 and will be removed in KunstmaanAdminDomainBundle 6.0. Register your custom configuration class as a service and override the "kunstmaan_admin.domain_configuration" service alias.',
17
                E_USER_DEPRECATED
18
            );
19
20
            // Inject the container back, to keep BC, if the user override the domain configuration with the "kunstmaan_admin.domain_configuration.class" parameter.
21
            if ($container->hasDefinition('kunstmaan_admin.domain_configuration')) {
22
                $container->getDefinition('kunstmaan_admin.domain_configuration')->setArguments([new Reference('service_container')]);
23
            }
24
        }
25 3
    }
26
}
27