Skip to content

Commit 3a854f8

Browse files
mbabkerostrolucky
authored andcommitted
Do not configure deprecated proxy options when native lazy ghost objects are enabled
1 parent a5c0ffb commit 3a854f8

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private function addOrmSection(ArrayNodeDefinition $node): void
474474
->children()
475475
->scalarNode('default_entity_manager')->end()
476476
->scalarNode('auto_generate_proxy_classes')->defaultValue(false)
477-
->info('Auto generate mode possible values are: "NEVER", "ALWAYS", "FILE_NOT_EXISTS", "EVAL", "FILE_NOT_EXISTS_OR_CHANGED"')
477+
->info('Auto generate mode possible values are: "NEVER", "ALWAYS", "FILE_NOT_EXISTS", "EVAL", "FILE_NOT_EXISTS_OR_CHANGED", this option is ignored when the "enable_native_lazy_objects" option is true')
478478
->validate()
479479
->ifTrue(function ($v) {
480480
$generationModes = $this->getAutoGenerateModes();
@@ -506,8 +506,14 @@ private function addOrmSection(ArrayNodeDefinition $node): void
506506
->defaultValue(! method_exists(ProxyFactory::class, 'resetUninitializedProxy'))
507507
->info('Enables the new implementation of proxies based on lazy ghosts instead of using the legacy implementation')
508508
->end()
509-
->scalarNode('proxy_dir')->defaultValue('%kernel.build_dir%/doctrine/orm/Proxies')->end()
510-
->scalarNode('proxy_namespace')->defaultValue('Proxies')->end()
509+
->scalarNode('proxy_dir')
510+
->defaultValue('%kernel.build_dir%/doctrine/orm/Proxies')
511+
->info('Configures the path where generated proxy classes are saved when using non-native lazy objects, this option is ignored when the "enable_native_lazy_objects" option is true')
512+
->end()
513+
->scalarNode('proxy_namespace')
514+
->defaultValue('Proxies')
515+
->info('Defines the root namespace for generated proxy classes when using non-native lazy objects, this option is ignored when the "enable_native_lazy_objects" option is true')
516+
->end()
511517
->arrayNode('controller_resolver')
512518
->canBeDisabled()
513519
->children()

src/DependencyInjection/DoctrineExtension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Doctrine\ORM\Mapping\Entity;
3232
use Doctrine\ORM\Mapping\LegacyReflectionFields;
3333
use Doctrine\ORM\Mapping\MappedSuperclass;
34+
use Doctrine\ORM\ORMSetup;
3435
use Doctrine\ORM\Proxy\Autoloader;
3536
use Doctrine\ORM\Proxy\ProxyFactory;
3637
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
@@ -703,6 +704,16 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $
703704

704705
if (PHP_VERSION_ID >= 80400 && class_exists(LegacyReflectionFields::class)) {
705706
$methods['enableNativeLazyObjects'] = $entityManager['enable_native_lazy_objects'];
707+
708+
// Do not set deprecated proxy configurations when native lazy objects are enabled with `doctrine/orm:^3.5`
709+
/** @phpstan-ignore function.alreadyNarrowedType */
710+
if ($entityManager['enable_native_lazy_objects'] && method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) {
711+
unset(
712+
$methods['setProxyDir'],
713+
$methods['setProxyNamespace'],
714+
$methods['setAutoGenerateProxyClasses'],
715+
);
716+
}
706717
}
707718

708719
if (isset($entityManager['fetch_mode_subselect_batch_size'])) {

0 commit comments

Comments
 (0)