Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clear lazy loading initializer after the service is successfully initialized #8877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function instantiateProxy(ContainerInterface $container, Definition $defi
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;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public function getProxyFactoryCode(Definition $definition, $id)

$instantiation new $proxyClass(
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
\$proxy->setProxyInitializer(null);

\$wrappedInstance = \$container->$methodName(false);

\$proxy->setProxyInitializer(null);

return true;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public function getFooService($lazyLoad = true)

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;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testGetProxyFactoryCode()
'%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
);
Expand Down