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 <matthieu@knplabs.com>
  23.  * @author Thibault Duplessis <thibault.duplessis@gmail.com>
  24.  */
  25. class FOSUserBundle extends Bundle
  26. {
  27.     public function build(ContainerBuilder $container)
  28.     {
  29.         parent::build($container);
  30.         $container->addCompilerPass(new ValidationPass());
  31.         $container->addCompilerPass(new InjectUserCheckerPass());
  32.         $container->addCompilerPass(new InjectRememberMeServicesPass());
  33.         $container->addCompilerPass(new CheckForSessionPass());
  34.         $container->addCompilerPass(new CheckForMailerPass());
  35.         $this->addRegisterMappingsPass($container);
  36.     }
  37.     private function addRegisterMappingsPass(ContainerBuilder $container)
  38.     {
  39.         $mappings = [
  40.             realpath(__DIR__.'/Resources/config/doctrine-mapping') => 'FOS\UserBundle\Model',
  41.         ];
  42.         if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
  43.             $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, ['fos_user.model_manager_name'], 'fos_user.backend_type_orm'));
  44.         }
  45.         if (class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) {
  46.             $container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, ['fos_user.model_manager_name'], 'fos_user.backend_type_mongodb'));
  47.         }
  48.         if (class_exists('Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass')) {
  49.             $container->addCompilerPass(DoctrineCouchDBMappingsPass::createXmlMappingDriver($mappings, ['fos_user.model_manager_name'], 'fos_user.backend_type_couchdb'));
  50.         }
  51.     }
  52. }