-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYarhonRouteGuardBundle.php
More file actions
54 lines (44 loc) · 2.47 KB
/
YarhonRouteGuardBundle.php
File metadata and controls
54 lines (44 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
*
* (c) Yaroslav Honcharuk <yaroslav.xs@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Yarhon\RouteGuardBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SymfonySecurityBundlePass;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SensioFrameworkExtraBundlePass;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SensioSecurityExpressionVoterPass;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\TwigBundlePass;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\ContainerClassMapPass;
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\InjectTaggedServicesPass;
use Yarhon\RouteGuardBundle\DependencyInjection\Container\ForeignExtensionAccessor;
use Yarhon\RouteGuardBundle\DependencyInjection\Container\ClassMapBuilder;
/**
* @author Yaroslav Honcharuk <yaroslav.xs@gmail.com>
*/
class YarhonRouteGuardBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$foreignExtensionAccessor = new ForeignExtensionAccessor();
$classMapBuilder = new ClassMapBuilder();
// We need to be able to remove SensioSecurityExpressionVoter before it is registered in "security.access.decision_manager" service
$container->addCompilerPass(new SensioSecurityExpressionVoterPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
// We use same type and priority as are used for \Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass
$container->addCompilerPass(new TwigBundlePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new SymfonySecurityBundlePass($foreignExtensionAccessor), PassConfig::TYPE_BEFORE_REMOVING, 100);
$container->addCompilerPass(new SensioFrameworkExtraBundlePass(), PassConfig::TYPE_BEFORE_REMOVING, 101);
$container->addCompilerPass(new InjectTaggedServicesPass(), PassConfig::TYPE_BEFORE_REMOVING, 0);
// We need only public services for the class map, so we include this pass at the very end, after removing all private services.
$container->addCompilerPass(new ContainerClassMapPass($classMapBuilder), PassConfig::TYPE_AFTER_REMOVING, 0);
}
}