merged branch jeremylivingston/proxy-init (PR #8877)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #8877). Discussion ---------- Clear lazy loading initializer after the service is successfully initialized Fixes #8875 Commits ------- da73102 Clear lazy loading initializer after the service is successfully initialized
This commit is contained in:
commit
70db3c3182
@ -51,10 +51,10 @@ class RuntimeInstantiator implements InstantiatorInterface
|
|||||||
return $this->factory->createProxy(
|
return $this->factory->createProxy(
|
||||||
$definition->getClass(),
|
$definition->getClass(),
|
||||||
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
|
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
|
||||||
$proxy->setProxyInitializer(null);
|
|
||||||
|
|
||||||
$wrappedInstance = call_user_func($realInstantiator);
|
$wrappedInstance = call_user_func($realInstantiator);
|
||||||
|
|
||||||
|
$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -75,10 +75,10 @@ class ProxyDumper implements DumperInterface
|
|||||||
|
|
||||||
$instantiation new $proxyClass(
|
$instantiation new $proxyClass(
|
||||||
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
|
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
|
||||||
\$proxy->setProxyInitializer(null);
|
|
||||||
|
|
||||||
\$wrappedInstance = \$container->$methodName(false);
|
\$wrappedInstance = \$container->$methodName(false);
|
||||||
|
|
||||||
|
\$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -50,10 +50,10 @@ class LazyServiceProjectServiceContainer extends Container
|
|||||||
|
|
||||||
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
|
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
|
||||||
function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
|
function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
|
||||||
$proxy->setProxyInitializer(null);
|
|
||||||
|
|
||||||
$wrappedInstance = $container->getFooService(false);
|
$wrappedInstance = $container->getFooService(false);
|
||||||
|
|
||||||
|
$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -10,10 +10,10 @@ class ProjectServiceContainer extends Container
|
|||||||
|
|
||||||
return $this->services['foo'] = new stdClass_%s(
|
return $this->services['foo'] = new stdClass_%s(
|
||||||
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
|
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
|
||||||
$proxy->setProxyInitializer(null);
|
|
||||||
|
|
||||||
$wrappedInstance = $container->getFooService(false);
|
$wrappedInstance = $container->getFooService(false);
|
||||||
|
|
||||||
|
$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -74,7 +74,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
'%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new '
|
'%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new '
|
||||||
. 'SymfonyBridgeProxyManagerLazyProxyTestsInstantiatorProxyDumperTest_%s(%wfunction '
|
. 'SymfonyBridgeProxyManagerLazyProxyTestsInstantiatorProxyDumperTest_%s(%wfunction '
|
||||||
. '(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {'
|
. '(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {'
|
||||||
. '%w$proxy->setProxyInitializer(null);%w$wrappedInstance = $container->getFooService(false);'
|
. '%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);'
|
||||||
. '%wreturn true;%w}%w);%w}%w',
|
. '%wreturn true;%w}%w);%w}%w',
|
||||||
$code
|
$code
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user