44
55namespace Meilisearch \Bundle \Tests ;
66
7+ use Composer \InstalledVersions ;
78use Doctrine \Bundle \DoctrineBundle \ConnectionFactory ;
9+ use Doctrine \Bundle \DoctrineBundle \Dbal \BlacklistSchemaAssetFilter ;
810use Doctrine \Bundle \DoctrineBundle \DoctrineBundle ;
9- use Doctrine \ORM \Configuration ;
1011use Doctrine \ORM \Mapping \LegacyReflectionFields ;
1112use Meilisearch \Bundle \MeilisearchBundle ;
1213use Symfony \Bridge \Doctrine \ArgumentResolver \EntityValueResolver ;
@@ -29,35 +30,64 @@ public function registerBundles(): iterable
2930
3031 protected function configureContainer (ContainerBuilder $ container , LoaderInterface $ loader ): void
3132 {
33+ $ loader ->load (__DIR__ .'/config/framework.yaml ' );
34+
35+ //$doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class);
36+ $ loader ->load (__DIR__ .'/config/doctrine.yaml ' );
3237 if (PHP_VERSION_ID >= 80000 ) {
33- if (class_exists (LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400 ) {
34- $ loader ->load (__DIR__ .'/config/config.yaml ' );
35- } else {
36- $ loader ->load (__DIR__ .'/config/config_old_proxy.yaml ' );
37- }
38+ // if ($doctrineBundleV3) {
39+ // $loader->load(__DIR__.'/config/doctrine.yaml');
40+ // } elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
41+ // $loader->load(__DIR__.'/config/doctrine_v2.yaml');
42+ // } else {
43+ // $loader->load(__DIR__.'/config/doctrine_old_proxy.yaml');
44+ // }
3845 } else {
39- $ loader ->load (__DIR__ .'/config/config_php7.yaml ' );
46+ $ container ->prependExtensionConfig ('framework ' , [
47+ 'annotations ' => true ,
48+ 'serializer ' => ['enable_annotations ' => true ],
49+ 'router ' => ['utf8 ' => true ],
50+ ]);
51+
52+ // $loader->load(__DIR__.'/config/doctrine_php7.yaml');
4053 }
4154 $ loader ->load (__DIR__ .'/config/meilisearch.yaml ' );
4255
43- if (\defined (ConnectionFactory::class.'::DEFAULT_SCHEME_MAP ' )) {
44- $ container ->prependExtensionConfig ('doctrine ' , [
45- 'orm ' => [
46- 'report_fields_where_declared ' => true ,
47- 'validate_xml_mapping ' => true ,
48- ],
49- ]);
50- }
56+ if (null !== $ doctrineBundleVersion = InstalledVersions::getVersion ('doctrine/doctrine-bundle ' )) {
57+ if (version_compare ($ doctrineBundleVersion , '2.8.0 ' , '>= ' )) {
58+ $ container ->prependExtensionConfig ('doctrine ' , [
59+ 'orm ' => [
60+ 'enable_lazy_ghost_objects ' => true ,
61+ ],
62+ ]);
63+ }
64+ // https://github.com/doctrine/DoctrineBundle/pull/1661
65+ if (version_compare ($ doctrineBundleVersion , '2.9.0 ' , '>= ' )) {
66+ $ container ->prependExtensionConfig ('doctrine ' , [
67+ 'orm ' => [
68+ 'report_fields_where_declared ' => true ,
69+ ],
70+ ]);
71+ }
5172
52- // @phpstan-ignore-next-line
53- if ( method_exists (Configuration::class, ' setLazyGhostObjectEnabled ' ) && Kernel:: VERSION_ID >= 60100 ) {
54- $ container -> prependExtensionConfig ( ' doctrine ' , [
55- ' orm ' => [
56- ' enable_lazy_ghost_objects ' => true ,
57- ],
58- ]);
73+ if (\ PHP_VERSION_ID >= 80400 && version_compare ( $ doctrineBundleVersion , ' 2.15.0 ' , ' >= ' )) {
74+ $ container -> prependExtensionConfig ( ' doctrine ' , [
75+ ' orm ' => [
76+ ' enable_native_lazy_objects ' => true ,
77+ ] ,
78+ ]);
79+ }
5980 }
6081
82+ // if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) {
83+ // $container->prependExtensionConfig('doctrine', [
84+ // 'orm' => [
85+ // 'report_fields_where_declared' => true,
86+ // 'validate_xml_mapping' => true,
87+ // ],
88+ // ]);
89+ // }
90+
6191 if (class_exists (EntityValueResolver::class)) {
6292 $ container ->prependExtensionConfig ('doctrine ' , [
6393 'orm ' => [
0 commit comments