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:
Fabien Potencier 2013-08-29 07:26:51 +02:00
commit 70db3c3182
5 changed files with 9 additions and 9 deletions

View File

@ -51,10 +51,10 @@ class RuntimeInstantiator implements InstantiatorInterface
return $this->factory->createProxy(
$definition->getClass(),
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
$proxy->setProxyInitializer(null);
$wrappedInstance = call_user_func($realInstantiator);
$proxy->setProxyInitializer(null);
return true;
}
);

View File

@ -75,10 +75,10 @@ class ProxyDumper implements DumperInterface
$instantiation new $proxyClass(
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
\$proxy->setProxyInitializer(null);
\$wrappedInstance = \$container->$methodName(false);
\$proxy->setProxyInitializer(null);
return true;
}
);

View File

@ -50,10 +50,10 @@ class LazyServiceProjectServiceContainer extends Container
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
$proxy->setProxyInitializer(null);
$wrappedInstance = $container->getFooService(false);
$proxy->setProxyInitializer(null);
return true;
}
);

View File

@ -10,10 +10,10 @@ class ProjectServiceContainer extends Container
return $this->services['foo'] = new stdClass_%s(
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
$proxy->setProxyInitializer(null);
$wrappedInstance = $container->getFooService(false);
$proxy->setProxyInitializer(null);
return true;
}
);

View File

@ -74,7 +74,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
'%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new '
. 'SymfonyBridgeProxyManagerLazyProxyTestsInstantiatorProxyDumperTest_%s(%wfunction '
. '(&$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',
$code
);