5
5
use Doctrine \Bundle \DoctrineBundle \Command \Proxy \ImportDoctrineCommand ;
6
6
use Doctrine \Bundle \DoctrineBundle \Dbal \ManagerRegistryAwareConnectionProvider ;
7
7
use Doctrine \Bundle \DoctrineBundle \Dbal \RegexSchemaAssetFilter ;
8
+ use Doctrine \Bundle \DoctrineBundle \DependencyInjection \Compiler \IdGeneratorPass ;
8
9
use Doctrine \Bundle \DoctrineBundle \DependencyInjection \Compiler \ServiceRepositoryCompilerPass ;
9
10
use Doctrine \Bundle \DoctrineBundle \EventSubscriber \EventSubscriberInterface ;
10
11
use Doctrine \Bundle \DoctrineBundle \Repository \ServiceEntityRepositoryInterface ;
15
16
use Doctrine \DBAL \Tools \Console \Command \ImportCommand ;
16
17
use Doctrine \DBAL \Tools \Console \ConnectionProvider ;
17
18
use Doctrine \ORM \EntityManagerInterface ;
19
+ use Doctrine \ORM \Id \AbstractIdGenerator ;
18
20
use Doctrine \ORM \Proxy \Autoloader ;
19
21
use Doctrine \ORM \UnitOfWork ;
20
22
use LogicException ;
21
23
use Symfony \Bridge \Doctrine \DependencyInjection \AbstractDoctrineExtension ;
24
+ use Symfony \Bridge \Doctrine \IdGenerator \UlidGenerator ;
25
+ use Symfony \Bridge \Doctrine \IdGenerator \UuidGenerator ;
22
26
use Symfony \Bridge \Doctrine \Messenger \DoctrineClearEntityManagerWorkerSubscriber ;
23
27
use Symfony \Bridge \Doctrine \Messenger \DoctrineTransactionMiddleware ;
24
28
use Symfony \Bridge \Doctrine \PropertyInfo \DoctrineExtractor ;
@@ -405,6 +409,14 @@ protected function ormLoad(array $config, ContainerBuilder $container)
405
409
$ container ->removeDefinition ('doctrine.orm.listeners.pdo_cache_adapter_doctrine_schema_subscriber ' );
406
410
}
407
411
412
+ if (! class_exists (UlidGenerator::class)) {
413
+ $ container ->removeDefinition ('doctrine.ulid_generator ' );
414
+ }
415
+
416
+ if (! class_exists (UuidGenerator::class)) {
417
+ $ container ->removeDefinition ('doctrine.uuid_generator ' );
418
+ }
419
+
408
420
$ entityManagers = [];
409
421
foreach (array_keys ($ config ['entity_managers ' ]) as $ name ) {
410
422
$ entityManagers [$ name ] = sprintf ('doctrine.orm.%s_entity_manager ' , $ name );
@@ -459,6 +471,9 @@ protected function ormLoad(array $config, ContainerBuilder $container)
459
471
$ container ->registerForAutoconfiguration (EventSubscriberInterface::class)
460
472
->addTag ('doctrine.event_subscriber ' );
461
473
474
+ $ container ->registerForAutoconfiguration (AbstractIdGenerator::class)
475
+ ->addTag (IdGeneratorPass::ID_GENERATOR_TAG );
476
+
462
477
/**
463
478
* @see DoctrineBundle::boot()
464
479
*/
@@ -477,6 +492,7 @@ protected function ormLoad(array $config, ContainerBuilder $container)
477
492
protected function loadOrmEntityManager (array $ entityManager , ContainerBuilder $ container )
478
493
{
479
494
$ ormConfigDef = $ container ->setDefinition (sprintf ('doctrine.orm.%s_configuration ' , $ entityManager ['name ' ]), new ChildDefinition ('doctrine.orm.configuration ' ));
495
+ $ ormConfigDef ->addTag (IdGeneratorPass::CONFIGURATION_TAG );
480
496
481
497
$ this ->loadOrmEntityManagerMappingInformation ($ entityManager , $ ormConfigDef , $ container );
482
498
$ this ->loadOrmCacheDrivers ($ entityManager , $ container );
0 commit comments