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

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