vendor/bundles/FOS/UserBundle/DependencyInjection/Compiler/SecurityEncoderFactoryPass.php
equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the FOSUserBundle package. |
|
5 * |
|
6 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace FOS\UserBundle\DependencyInjection\Compiler; |
|
13 |
|
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
15 use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
16 use Symfony\Component\DependencyInjection\Alias; |
|
17 |
|
18 /** |
|
19 * Overwrites the existing encoder factory and injects the old one in the FOSUserBundle implementation |
|
20 * |
|
21 * @author Christophe Coevoet <stof@notk.org> |
|
22 */ |
|
23 class SecurityEncoderFactoryPass implements CompilerPassInterface |
|
24 { |
|
25 public function process(ContainerBuilder $container) |
|
26 { |
|
27 if ($container->hasAlias('security.encoder_factory')) { |
|
28 // security.encoder_factory is an alias. |
|
29 // Register a private alias for this service to inject it as the parent |
|
30 $container->setAlias('fos_user.encoder_factory.parent', new Alias((string) $container->getAlias('security.encoder_factory'), false)); |
|
31 } else { |
|
32 // security.encoder_factory is a definition. |
|
33 // Register it again as a private service to inject it as the parent |
|
34 $definition = $container->getDefinition('security.encoder_factory'); |
|
35 $definition->setPublic(false); |
|
36 $container->setDefinition('fos_user.encoder_factory.parent', $definition); |
|
37 } |
|
38 |
|
39 $container->setAlias('security.encoder_factory', 'fos_user.encoder_factory'); |
|
40 } |
|
41 } |