vendor/symfony-cmf/seo-bundle/src/CmfSeoBundle.php line 22

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony CMF package.
  4.  *
  5.  * (c) 2011-2017 Symfony CMF
  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 Symfony\Cmf\Bundle\SeoBundle;
  11. use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
  12. use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
  13. use Symfony\Cmf\Bundle\SeoBundle\DependencyInjection\Compiler\RegisterExtractorsPass;
  14. use Symfony\Cmf\Bundle\SeoBundle\DependencyInjection\Compiler\RegisterSuggestionProviderPass;
  15. use Symfony\Cmf\Bundle\SeoBundle\DependencyInjection\Compiler\RegisterUrlInformationProviderPass;
  16. use Symfony\Component\DependencyInjection\ContainerBuilder;
  17. use Symfony\Component\HttpKernel\Bundle\Bundle;
  18. class CmfSeoBundle extends Bundle
  19. {
  20.     public function build(ContainerBuilder $container)
  21.     {
  22.         $container->addCompilerPass(new RegisterExtractorsPass());
  23.         $container->addCompilerPass(new RegisterSuggestionProviderPass());
  24.         $container->addCompilerPass(new RegisterUrlInformationProviderPass());
  25.         $this->buildPhpcrCompilerPass($container);
  26.         $this->buildOrmCompilerPass($container);
  27.     }
  28.     /**
  29.      * Creates and registers compiler passes for PHPCR-ODM mapping if both the
  30.      * phpcr-odm and the phpcr-bundle are present.
  31.      *
  32.      * @param ContainerBuilder $container
  33.      */
  34.     private function buildPhpcrCompilerPass(ContainerBuilder $container)
  35.     {
  36.         if (!class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')
  37.             || !class_exists('Doctrine\ODM\PHPCR\Version')
  38.         ) {
  39.             return;
  40.         }
  41.         $container->addCompilerPass(
  42.             DoctrinePhpcrMappingsPass::createXmlMappingDriver(
  43.                 [
  44.                     $this->getPath().'/Resources/config/doctrine-model' => 'Symfony\Cmf\Bundle\SeoBundle\Model',
  45.                     $this->getPath().'/Resources/config/doctrine-phpcr' => 'Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr',
  46.                 ],
  47.                 ['cmf_seo.dynamic.persistence.phpcr.manager_name'],
  48.                 'cmf_seo.backend_type_phpcr',
  49.                 ['CmfSeoBundle' => 'Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr']
  50.             )
  51.         );
  52.     }
  53.     /**
  54.      * Creates and registers compiler passes for ORM mappings if both doctrine
  55.      * ORM and a suitable compiler pass implementation are available.
  56.      *
  57.      * @param ContainerBuilder $container
  58.      */
  59.     private function buildOrmCompilerPass(ContainerBuilder $container)
  60.     {
  61.         if (!class_exists('Doctrine\ORM\Version')
  62.             || !class_exists('Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass')
  63.             || !class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')
  64.         ) {
  65.             return;
  66.         }
  67.         $container->addCompilerPass(
  68.             DoctrineOrmMappingsPass::createXmlMappingDriver(
  69.                 [
  70.                     $this->getPath().'/Resources/config/doctrine-model' => 'Symfony\Cmf\Bundle\SeoBundle\Model',
  71.                 ],
  72.                 ['cmf_seo.dynamic.persistence.orm.manager_name'],
  73.                 'cmf_seo.backend_type_orm',
  74.                 ['CmfSeoBundle' => 'Symfony\Cmf\Bundle\SeoBundle\Model']
  75.             )
  76.         );
  77.     }
  78. }