Completed
Push — master ( ae5e03...0447ee )
by Jeroen
10:35 queued 04:37
created

DeprecateClassParametersPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 9.344
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
3
namespace Kunstmaan\AdminBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * @internal
10
 */
11
final class DeprecateClassParametersPass implements CompilerPassInterface
12
{
13 5
    public function process(ContainerBuilder $container)
14
    {
15
        $expectedValues = [
16 5
            'kunstmaan_admin.consoleexception.class' => \Kunstmaan\AdminBundle\EventListener\ConsoleExceptionListener::class,
17
            'kunstmaan_admin.menubuilder.class' => \Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder::class,
18
            'kunstmaan_admin.admin_panel.class' => \Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanel::class,
19
            'kunstmaan_admin.login.listener.class' => \Kunstmaan\AdminBundle\EventListener\LoginListener::class,
20
            'kunstmaan_admin.admin_locale.listener.class' => \Kunstmaan\AdminBundle\EventListener\AdminLocaleListener::class,
21
            'kunstmaan_admin.acl.helper.class' => \Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::class,
22
            'kunstmaan_admin.acl.native.helper.class' => \Kunstmaan\AdminBundle\Helper\Security\Acl\AclNativeHelper::class,
23
            'kunstmaan_admin.security.acl.permission.map.class' => \Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionMap::class,
24
            'kunstmaan_admin.clone.listener.class' => \Kunstmaan\AdminBundle\EventListener\CloneListener::class,
25
            'kunstmaan_admin.session_security.class' => \Kunstmaan\AdminBundle\EventListener\SessionSecurityListener::class,
26
            'kunstmaan_admin.password_resetting.listener.class' => \Kunstmaan\AdminBundle\EventListener\PasswordResettingListener::class,
27
            'kunstmaan_admin.password_check.listener.class' => \Kunstmaan\AdminBundle\EventListener\PasswordCheckListener::class,
28
            'kunstmaan_admin.domain_configuration.class' => \Kunstmaan\AdminBundle\Helper\DomainConfiguration::class,
29
            'kunstmaan_admin.validator.password_restrictions.class' => \Kunstmaan\AdminBundle\Validator\Constraints\PasswordRestrictionsValidator::class,
30
            'kunstmaan_admin.adminroute.helper.class' => \Kunstmaan\AdminBundle\Helper\AdminRouteHelper::class,
31
            'kunstmaan_admin.adminroute.twig.class' => \Kunstmaan\AdminBundle\Twig\AdminRouteHelperTwigExtension::class,
32
            'kunstmaan_admin.exception.listener.class' => \Kunstmaan\AdminBundle\EventListener\ExceptionSubscriber::class,
33
            'kunstmaan_admin.toolbar.listener.class' => \Kunstmaan\AdminBundle\EventListener\ToolbarListener::class,
34
            'kunstmaan_admin.toolbar.collector.bundle.class' => \Kunstmaan\AdminBundle\Toolbar\BundleVersionDataCollector::class,
35
            'kunstmaan_admin.toolbar.collector.exception.class' => \Kunstmaan\AdminBundle\Toolbar\ExceptionDataCollector::class,
36
        ];
37
38 5
        foreach ($expectedValues as $parameter => $expectedValue) {
39 5
            if (false === $container->hasParameter($parameter)) {
40 2
                continue;
41
            }
42
43 4
            $currentValue = $container->getParameter($parameter);
44 4
            if ($currentValue !== $expectedValue) {
45 1
                @trigger_error(sprintf('Using the "%s" parameter to change the class of the service definition is deprecated in KunstmaanAdminBundle 5.2 and will be removed in KunstmaanAdminBundle 6.0. Use service decoration or a service alias instead.', $parameter), E_USER_DEPRECATED);
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...
46
            }
47
        }
48 5
    }
49
}
50