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

Skip to content

Commit 70db3c3

Browse files
committed
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
2 parents 196227b + 39b610d commit 70db3c3

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function instantiateProxy(ContainerInterface $container, Definition $defi
5151
return $this->factory->createProxy(
5252
$definition->getClass(),
5353
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
54-
$proxy->setProxyInitializer(null);
55-
5654
$wrappedInstance = call_user_func($realInstantiator);
5755

56+
$proxy->setProxyInitializer(null);
57+
5858
return true;
5959
}
6060
);

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public function getProxyFactoryCode(Definition $definition, $id)
7575
7676
$instantiation new $proxyClass(
7777
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
78-
\$proxy->setProxyInitializer(null);
79-
8078
\$wrappedInstance = \$container->$methodName(false);
8179
80+
\$proxy->setProxyInitializer(null);
81+
8282
return true;
8383
}
8484
);

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public function getFooService($lazyLoad = true)
5050

5151
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
5252
function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
53-
$proxy->setProxyInitializer(null);
54-
5553
$wrappedInstance = $container->getFooService(false);
5654

55+
$proxy->setProxyInitializer(null);
56+
5757
return true;
5858
}
5959
);

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class ProjectServiceContainer extends Container
1010

1111
return $this->services['foo'] = new stdClass_%s(
1212
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
13-
$proxy->setProxyInitializer(null);
14-
1513
$wrappedInstance = $container->getFooService(false);
1614

15+
$proxy->setProxyInitializer(null);
16+
1717
return true;
1818
}
1919
);

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testGetProxyFactoryCode()
7474
'%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new '
7575
. 'SymfonyBridgeProxyManagerLazyProxyTestsInstantiatorProxyDumperTest_%s(%wfunction '
7676
. '(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {'
77-
. '%w$proxy->setProxyInitializer(null);%w$wrappedInstance = $container->getFooService(false);'
77+
. '%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);'
7878
. '%wreturn true;%w}%w);%w}%w',
7979
$code
8080
);

0 commit comments

Comments
 (0)