8000 Fix bug when using an private aliased factory service · dunglas/symfony@de406c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit de406c0

Browse files
wouterjfabpot
authored andcommitted
Fix bug when using an private aliased factory service
1 parent d0cac39 commit de406c0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ private function updateFactoryServiceReference($factoryService, $currentId, $new
131131
return;
132132
}
133133

134-
return $currentId === $factoryService ? $newId : $currentId;
134+
return $currentId === $factoryService ? $newId : $factoryService;
135135
}
136136
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
1717

18+
require_once __DIR__.'/../Fixtures/includes/foo.php';
19+
1820
class ReplaceAliasByActualDefinitionPassTest extends \PHPUnit_Framework_TestCase
1921
{
2022
public function testProcess()
@@ -44,6 +46,26 @@ public function testProcess()
4446
$this->assertSame('b_alias', $aDefinition->getFactoryService());
4547
}
4648

49+
/**
50+
* @group legacy
51+
*/
52+
public function testPrivateAliasesInFactory()
53+
{
54+
$container = new ContainerBuilder();
55+
56+
$container->register('a', 'FooClass');
57+
$container->register('b', 'FooClass')
58+
->setFactoryService('a')
59+
->setFactoryMethod('getInstance');
60+
61+
$container->register('c', 'stdClass')->setPublic(false);
62+
$container->setAlias('c_alias', 'c');
63+
64+
$this->process($container);
65+
66+
$this->assertInstanceOf('FooClass', $container->get('b'));
67+
}
68+
4769
/**
4870
* @expectedException \InvalidArgumentException
4971
*/

0 commit comments

Comments
 (0)
0