Skip to content

Commit 2a68260

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: fixed CS [BrowserKit] Corrected HTTP_HOST logic #15398 resolve aliases in factory services Remove invalid CSS white-space value Fix FileSystem tests on Windows
2 parents e3b9e81 + 8c80015 commit 2a68260

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Compiler/ResolveReferencesToAliasesPass.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function process(ContainerBuilder $container)
4444
$definition->setMethodCalls($this->processArguments($definition->getMethodCalls()));
4545
$definition->setProperties($this->processArguments($definition->getProperties()));
4646
$definition->setFactory($this->processFactory($definition->getFactory()));
47+
48+
if (null !== $factoryService = $definition->getFactoryService(false)) {
49+
$definition->setFactoryService($this->processFactoryService($factoryService));
50+
}
4751
}
4852

4953
foreach ($container->getAliases() as $id => $alias) {
@@ -78,6 +82,15 @@ private function processArguments(array $arguments)
7882
return $arguments;
7983
}
8084

85+
private function processFactoryService($factoryService)
86+
{
87+
if (null === $factoryService) {
88+
return;
89+
}
90+
91+
return $this->getDefinitionId($factoryService);
92+
}
93+
8194
private function processFactory($factory)
8295
{
8396
if (null === $factory || !is_array($factory) || !$factory[0] instanceof Reference) {

Tests/Compiler/ResolveReferencesToAliasesPassTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ public function testResolveFactory()
8282
$this->assertSame('Factory', (string) $resolvedBarFactory[0]);
8383
}
8484

85+
/**
86+
* @group legacy
87+
*/
88+
public function testResolveFactoryService()
89+
{
90+
$container = new ContainerBuilder();
91+
$container->register('factory', 'Factory');
92+
$container->setAlias('factory_alias', new Alias('factory'));
93+
$foo = new Definition();
94+
$foo->setFactoryService('factory_alias');
95+
$foo->setFactoryMethod('createFoo');
96+
$container->setDefinition('foo', $foo);
97+
98+
$this->process($container);
99+
100+
$this->assertSame('factory', $foo->getFactoryService());
101+
}
102+
85103
protected function process(ContainerBuilder $container)
86104
{
87105
$pass = new ResolveReferencesToAliasesPass();

0 commit comments

Comments
 (0)