diff -r 806e57d67020 -r e54dfe4d0b2b vendor/bundles/FOS/UserBundle/DependencyInjection/Compiler/SecurityEncoderFactoryPass.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/bundles/FOS/UserBundle/DependencyInjection/Compiler/SecurityEncoderFactoryPass.php Fri Sep 30 11:24:53 2011 +0200 @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace FOS\UserBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Alias; + +/** + * Overwrites the existing encoder factory and injects the old one in the FOSUserBundle implementation + * + * @author Christophe Coevoet + */ +class SecurityEncoderFactoryPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if ($container->hasAlias('security.encoder_factory')) { + // security.encoder_factory is an alias. + // Register a private alias for this service to inject it as the parent + $container->setAlias('fos_user.encoder_factory.parent', new Alias((string) $container->getAlias('security.encoder_factory'), false)); + } else { + // security.encoder_factory is a definition. + // Register it again as a private service to inject it as the parent + $definition = $container->getDefinition('security.encoder_factory'); + $definition->setPublic(false); + $container->setDefinition('fos_user.encoder_factory.parent', $definition); + } + + $container->setAlias('security.encoder_factory', 'fos_user.encoder_factory'); + } +}