vendor/doctrine/doctrine-bundle/Mapping/MappingDriver.php line 27

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Mapping;
  3. use Doctrine\ORM\Mapping\ClassMetadataInfo;
  4. use Doctrine\Persistence\Mapping\ClassMetadata;
  5. use Doctrine\Persistence\Mapping\Driver\MappingDriver as MappingDriverInterface;
  6. use Psr\Container\ContainerInterface;
  7. class MappingDriver implements MappingDriverInterface
  8. {
  9.     /** @var MappingDriverInterface */
  10.     private $driver;
  11.     /** @var ContainerInterface */
  12.     private $idGeneratorLocator;
  13.     public function __construct(MappingDriverInterface $driverContainerInterface $idGeneratorLocator)
  14.     {
  15.         $this->driver             $driver;
  16.         $this->idGeneratorLocator $idGeneratorLocator;
  17.     }
  18.     /**
  19.      * {@inheritDoc}
  20.      */
  21.     public function getAllClassNames()
  22.     {
  23.         return $this->driver->getAllClassNames();
  24.     }
  25.     /**
  26.      * {@inheritDoc}
  27.      */
  28.     public function isTransient($className): bool
  29.     {
  30.         return $this->driver->isTransient($className);
  31.     }
  32.     /**
  33.      * {@inheritDoc}
  34.      */
  35.     public function loadMetadataForClass($classNameClassMetadata $metadata): void
  36.     {
  37.         $this->driver->loadMetadataForClass($className$metadata);
  38.         if (
  39.             ! $metadata instanceof ClassMetadataInfo
  40.             || $metadata->generatorType !== ClassMetadataInfo::GENERATOR_TYPE_CUSTOM
  41.             || ! isset($metadata->customGeneratorDefinition['class'])
  42.             || ! $this->idGeneratorLocator->has($metadata->customGeneratorDefinition['class'])
  43.         ) {
  44.             return;
  45.         }
  46.         $idGenerator $this->idGeneratorLocator->get($metadata->customGeneratorDefinition['class']);
  47.         $metadata->setCustomGeneratorDefinition(['instance' => $idGenerator] + $metadata->customGeneratorDefinition);
  48.         $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
  49.     }
  50.     /**
  51.      * Returns the inner driver
  52.      */
  53.     public function getDriver(): MappingDriverInterface
  54.     {
  55.         return $this->driver;
  56.     }
  57. }