File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
DependencyInjection/Compiler Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ doctrine:
3131 controller_resolver :
3232 auto_mapping : false
3333 enable_lazy_ghost_objects : true
34- enable_native_lazy_objects : true
3534 mappings :
3635 App :
3736 type : attribute
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace App \DependencyInjection \Compiler ;
4+
5+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
6+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
7+
8+ class DoctrineNativeLazyObjectsPass implements CompilerPassInterface
9+ {
10+ public function process (ContainerBuilder $ container ): void
11+ {
12+ if (PHP_VERSION_ID < 80400 ) {
13+ return ;
14+ }
15+
16+ $ configurations = [
17+ 'doctrine.orm.configuration ' ,
18+ 'doctrine.orm.default_configuration ' ,
19+ ];
20+
21+ foreach ($ configurations as $ configuration ) {
22+ if (!$ container ->hasDefinition ($ configuration )) {
23+ continue ;
24+ }
25+
26+ $ definition = $ container ->getDefinition ($ configuration );
27+ $ definition ->addMethodCall ('enableNativeLazyObjects ' , [true ]);
28+ }
29+ }
30+ }
Original file line number Diff line number Diff line change 22
33namespace App ;
44
5+ use App \DependencyInjection \Compiler \DoctrineNativeLazyObjectsPass ;
56use App \DependencyInjection \Compiler \SetDocLinksPass ;
67use Symfony \Bundle \FrameworkBundle \Kernel \MicroKernelTrait ;
78use Symfony \Component \DependencyInjection \ContainerBuilder ;
@@ -19,5 +20,6 @@ public function getProjectDir(): string
1920 protected function build (ContainerBuilder $ container ): void
2021 {
2122 $ container ->addCompilerPass (new SetDocLinksPass ());
23+ $ container ->addCompilerPass (new DoctrineNativeLazyObjectsPass ());
2224 }
2325}
You can’t perform that action at this time.
0 commit comments