[DoctrineBridge] [DX] Improve condition for exception text in ManagerRegistry to avoid confusion

This commit is contained in:
Guilliam Xavier 2020-01-20 10:07:41 +01:00 committed by Nicolas Grekas
parent c2e17645c2
commit 0d47fdfb49
1 changed files with 2 additions and 1 deletions

View File

@ -13,6 +13,7 @@ namespace Symfony\Bridge\Doctrine;
use Doctrine\Persistence\AbstractManagerRegistry;
use ProxyManager\Proxy\LazyLoadingInterface;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Component\DependencyInjection\Container;
/**
@ -46,7 +47,7 @@ abstract class ManagerRegistry extends AbstractManagerRegistry
$manager = $this->container->get($name);
if (!$manager instanceof LazyLoadingInterface) {
throw new \LogicException('Resetting a non-lazy manager service is not supported. '.(interface_exists(LazyLoadingInterface::class) ? sprintf('Declare the "%s" service as lazy.', $name) : 'Try running "composer require symfony/proxy-manager-bridge".'));
throw new \LogicException('Resetting a non-lazy manager service is not supported. '.(interface_exists(LazyLoadingInterface::class) && class_exists(RuntimeInstantiator::class) ? sprintf('Declare the "%s" service as lazy.', $name) : 'Try running "composer require symfony/proxy-manager-bridge".'));
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {