Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de406c0

Browse filesBrowse files
wouterjfabpot
authored andcommitted
Fix bug when using an private aliased factory service
1 parent d0cac39 commit de406c0
Copy full SHA for de406c0

File tree

2 files changed

+23
-1
lines changed
Filter options

2 files changed

+23
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php
+22Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.