vendor/alterphp/easyadmin-extension-bundle/src/EasyAdminExtensionBundle.php line 11

Open in your IDE?
  1. <?php
  2. namespace AlterPHP\EasyAdminExtensionBundle;
  3. use AlterPHP\EasyAdminExtensionBundle\DependencyInjection\Compiler\TwigPathPass;
  4. use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
  5. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  6. use Symfony\Component\DependencyInjection\ContainerBuilder;
  7. use Symfony\Component\HttpKernel\Bundle\Bundle;
  8. class EasyAdminExtensionBundle extends Bundle
  9. {
  10.     public function build(ContainerBuilder $container)
  11.     {
  12.         parent::build($container);
  13.         $container->addCompilerPass(new TwigPathPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
  14.         $this->addRegisterMappingsPass($container);
  15.     }
  16.     /**
  17.      * Register storage mapping for model-based persisted objects from EasyAdminExtension.
  18.      * Much inspired from FOSUserBundle implementation.
  19.      *
  20.      * @see  https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/FOSUserBundle.php
  21.      *
  22.      * @param ContainerBuilder $container
  23.      *
  24.      * @throws \ReflectionException
  25.      */
  26.     private function addRegisterMappingsPass(ContainerBuilder $container)
  27.     {
  28.         $easyAdminExtensionBundleRefl = new \ReflectionClass($this);
  29.         if ($easyAdminExtensionBundleRefl->isUserDefined()) {
  30.             $easyAdminExtensionBundlePath = \dirname((string) $easyAdminExtensionBundleRefl->getFileName());
  31.             $easyAdminExtensionDoctrineMapping $easyAdminExtensionBundlePath.'/Resources/config/doctrine-mapping';
  32.             $mappings = array(
  33.                 \realpath($easyAdminExtensionDoctrineMapping) => 'AlterPHP\EasyAdminExtensionBundle\Model',
  34.             );
  35.             if (\class_exists(DoctrineOrmMappingsPass::class)) {
  36.                 $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings));
  37.             }
  38.         }
  39.     }
  40. }