vendor/doctrine/doctrine-bundle/Mapping/ClassMetadataFactory.php line 16

  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Mapping;
  3. use Doctrine\ORM\Id\AbstractIdGenerator;
  4. use Doctrine\ORM\Mapping\ClassMetadata;
  5. use Doctrine\ORM\Mapping\ClassMetadataFactory as BaseClassMetadataFactory;
  6. use function assert;
  7. class ClassMetadataFactory extends BaseClassMetadataFactory
  8. {
  9.     /**
  10.      * {@inheritDoc}
  11.      */
  12.     protected function doLoadMetadata($class$parent$rootEntityFound, array $nonSuperclassParents): void
  13.     {
  14.         parent::doLoadMetadata($class$parent$rootEntityFound$nonSuperclassParents);
  15.         $customGeneratorDefinition $class->customGeneratorDefinition;
  16.         if (! isset($customGeneratorDefinition['instance'])) {
  17.             return;
  18.         }
  19.         assert($customGeneratorDefinition['instance'] instanceof AbstractIdGenerator);
  20.         $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
  21.         $class->setIdGenerator($customGeneratorDefinition['instance']);
  22.         unset($customGeneratorDefinition['instance']);
  23.         $class->setCustomGeneratorDefinition($customGeneratorDefinition);
  24.     }
  25. }