vendor/friendsofsymfony/user-bundle/FOSUserBundle.php line 29

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSUserBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace FOS\UserBundle;
  11. use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass;
  12. use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
  13. use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass;
  14. use FOS\UserBundle\DependencyInjection\Compiler\CheckForMailerPass;
  15. use FOS\UserBundle\DependencyInjection\Compiler\CheckForSessionPass;
  16. use FOS\UserBundle\DependencyInjection\Compiler\InjectRememberMeServicesPass;
  17. use FOS\UserBundle\DependencyInjection\Compiler\InjectUserCheckerPass;
  18. use FOS\UserBundle\DependencyInjection\Compiler\ValidationPass;
  19. use Symfony\Component\DependencyInjection\ContainerBuilder;
  20. use Symfony\Component\HttpKernel\Bundle\Bundle;
  21. /**
  22.  * @author Matthieu Bontemps <[email protected]>
  23.  * @author Thibault Duplessis <[email protected]>
  24.  */
  25. class FOSUserBundle extends Bundle
  26. {
  27.     /**
  28.      * @param ContainerBuilder $container
  29.      */
  30.     public function build(ContainerBuilder $container)
  31.     {
  32.         parent::build($container);
  33.         $container->addCompilerPass(new ValidationPass());
  34.         $container->addCompilerPass(new InjectUserCheckerPass());
  35.         $container->addCompilerPass(new InjectRememberMeServicesPass());
  36.         $container->addCompilerPass(new CheckForSessionPass());
  37.         $container->addCompilerPass(new CheckForMailerPass());
  38.         $this->addRegisterMappingsPass($container);
  39.     }
  40.     /**
  41.      * @param ContainerBuilder $container
  42.      */
  43.     private function addRegisterMappingsPass(ContainerBuilder $container)
  44.     {
  45.         $mappings = array(
  46.             realpath(__DIR__.'/Resources/config/doctrine-mapping') => 'FOS\UserBundle\Model',
  47.         );
  48.         if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
  49.             $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('fos_user.model_manager_name'), 'fos_user.backend_type_orm'));
  50.         }
  51.         if (class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) {
  52.             $container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, array('fos_user.model_manager_name'), 'fos_user.backend_type_mongodb'));
  53.         }
  54.         if (class_exists('Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass')) {
  55.             $container->addCompilerPass(DoctrineCouchDBMappingsPass::createXmlMappingDriver($mappings, array('fos_user.model_manager_name'), 'fos_user.backend_type_couchdb'));
  56.         }
  57.     }
  58. }