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

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.     private MappingDriverInterface $driver;
  10.     private ContainerInterface $idGeneratorLocator;
  11.     public function __construct(MappingDriverInterface $driverContainerInterface $idGeneratorLocator)
  12.     {
  13.         $this->driver             $driver;
  14.         $this->idGeneratorLocator $idGeneratorLocator;
  15.     }
  16.     /**
  17.      * {@inheritDoc}
  18.      */
  19.     public function getAllClassNames()
  20.     {
  21.         return $this->driver->getAllClassNames();
  22.     }
  23.     /**
  24.      * {@inheritDoc}
  25.      */
  26.     public function isTransient($className): bool
  27.     {
  28.         return $this->driver->isTransient($className);
  29.     }
  30.     /**
  31.      * {@inheritDoc}
  32.      */
  33.     public function loadMetadataForClass($classNameClassMetadata $metadata): void
  34.     {
  35.         $this->driver->loadMetadataForClass($className$metadata);
  36.         if (
  37.             ! $metadata instanceof ClassMetadataInfo
  38.             || $metadata->generatorType !== ClassMetadataInfo::GENERATOR_TYPE_CUSTOM
  39.             || ! isset($metadata->customGeneratorDefinition['class'])
  40.             || ! $this->idGeneratorLocator->has($metadata->customGeneratorDefinition['class'])
  41.         ) {
  42.             return;
  43.         }
  44.         $idGenerator $this->idGeneratorLocator->get($metadata->customGeneratorDefinition['class']);
  45.         $metadata->setCustomGeneratorDefinition(['instance' => $idGenerator] + $metadata->customGeneratorDefinition);
  46.         $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
  47.     }
  48.     /**
  49.      * Returns the inner driver
  50.      */
  51.     public function getDriver(): MappingDriverInterface
  52.     {
  53.         return $this->driver;
  54.     }
  55. }