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

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