[ProxyManagerBridge] Fixed support of private services
This commit is contained in:
parent
eeb53ee2ed
commit
198bee0916
@ -57,7 +57,7 @@ class ProxyDumper implements DumperInterface
|
||||
$instantiation = 'return';
|
||||
|
||||
if ($definition->isShared()) {
|
||||
$instantiation .= " \$this->services['$id'] =";
|
||||
$instantiation .= sprintf(' $this->%s[\'%s\'] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', $id);
|
||||
}
|
||||
|
||||
if (null === $factoryCode) {
|
||||
|
@ -83,6 +83,34 @@ class ProxyDumperTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPrivatePublicDefinitions
|
||||
*/
|
||||
public function testCorrectAssigning(Definition $definition, $access)
|
||||
{
|
||||
$definition->setLazy(true);
|
||||
|
||||
$code = $this->dumper->getProxyFactoryCode($definition, 'foo', '$this->getFoo2Service(false)');
|
||||
|
||||
$this->assertStringMatchesFormat('%A$this->'.$access.'[\'foo\'] = %A', $code);
|
||||
}
|
||||
|
||||
public function getPrivatePublicDefinitions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(false),
|
||||
'privates',
|
||||
),
|
||||
array(
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(true),
|
||||
'services',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
|
Reference in New Issue
Block a user