caisse-bliss/vendor/doctrine/doctrine-bundle/Mapping/ClassMetadataFactory.php

34 lines
1.1 KiB
PHP
Raw Normal View History

2023-06-19 12:13:30 +02:00
<?php
namespace Doctrine\Bundle\DoctrineBundle\Mapping;
use Doctrine\ORM\Id\AbstractIdGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory as BaseClassMetadataFactory;
use function assert;
class ClassMetadataFactory extends BaseClassMetadataFactory
{
/**
* {@inheritDoc}
*/
protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents): void
{
parent::doLoadMetadata($class, $parent, $rootEntityFound, $nonSuperclassParents);
$customGeneratorDefinition = $class->customGeneratorDefinition;
if (! isset($customGeneratorDefinition['instance'])) {
return;
}
assert($customGeneratorDefinition['instance'] instanceof AbstractIdGenerator);
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
$class->setIdGenerator($customGeneratorDefinition['instance']);
unset($customGeneratorDefinition['instance']);
$class->setCustomGeneratorDefinition($customGeneratorDefinition);
}
}