#17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features

This commit is contained in:
Marco Pivetta 2016-02-24 13:24:03 -05:00 committed by Fabien Potencier
parent b9cd91d342
commit a8f1a10e9e
3 changed files with 3 additions and 7 deletions

View File

@ -119,8 +119,6 @@ EOF;
}
/**
* @param Definition $definition
*
* @return ClassGenerator
*/
private function generateProxyClass(Definition $definition)

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper;
use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@ -49,8 +50,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testDumpContainerWithProxyServiceWillShareProxies()
{
// detecting ProxyManager v2
if (class_exists('ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor')) {
if (class_exists(StaticProxyConstructor::class)) { // detecting ProxyManager v2
require_once __DIR__.'/../Fixtures/php/lazy_service_with_hints.php';
} else {
require_once __DIR__.'/../Fixtures/php/lazy_service.php';

View File

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