Skip to content

Commit

Permalink
Use LazyGhostObject for proxy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jan 22, 2025
1 parent 783d281 commit 6d1cacd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"php": "^8.1",
"ext-mongodb": "^1.16",
"composer-runtime-api": "^2.0",
"doctrine/mongodb-odm": "^2.6",
"doctrine/mongodb-odm": "^2.10@dev",
"doctrine/persistence": "^3.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/config": "^6.4 || ^7.0",
Expand Down
4 changes: 2 additions & 2 deletions config/mongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Bundle\MongoDBBundle\Repository\ContainerRepositoryFactory;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener;
use ProxyManager\Proxy\GhostObjectInterface;
use Doctrine\Persistence\Proxy;
use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
Expand Down Expand Up @@ -54,7 +54,7 @@
'%doctrine_mongodb.odm.document_managers%',
'%doctrine_mongodb.odm.default_connection%',
'%doctrine_mongodb.odm.default_document_manager%',
GhostObjectInterface::class,
Proxy::class,
service('service_container'),
])

Expand Down
7 changes: 2 additions & 5 deletions src/DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use function in_array;
use function interface_exists;
use function is_dir;
use function method_exists;
use function sprintf;

/**
Expand Down Expand Up @@ -255,12 +254,10 @@ protected function loadDocumentManager(array $documentManager, string|null $defa
'setPersistentCollectionDir' => '%doctrine_mongodb.odm.persistent_collection_dir%',
'setPersistentCollectionNamespace' => '%doctrine_mongodb.odm.persistent_collection_namespace%',
'setAutoGeneratePersistentCollectionClasses' => '%doctrine_mongodb.odm.auto_generate_persistent_collection_classes%',
'setUseLazyGhostObject' => true,
'setUseTransactionalFlush' => $documentManager['use_transactional_flush'],
];

if (method_exists(ODMConfiguration::class, 'setUseTransactionalFlush')) {
$methods['setUseTransactionalFlush'] = $documentManager['use_transactional_flush'];
}

if ($documentManager['repository_factory']) {
$methods['setRepositoryFactory'] = new Reference($documentManager['repository_factory']);
}
Expand Down

0 comments on commit 6d1cacd

Please sign in to comment.