8000 merged branch fabpot/synthetic-service-fix (PR #6827) · weaverryan/symfony@115114b · GitHub
[go: up one dir, main page]

Skip to content

Commit 115114b

Browse files
committed
merged branch fabpot/synthetic-service-fix (PR symfony#6827)
This PR was merged into the 2.0 branch. Commits ------- 4119caf [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder Discussion ---------- [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a --------------------------------------------------------------------------- by stof at 2013-01-22T00:14:29Z :+1:
2 parents 5663820 + 4119caf commit 115114b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ public function findDefinition($id)
725725
*/
726726
private function createService(Definition $definition, $id)
727727
{
728+
if ($definition->isSynthetic()) {
729+
throw new \RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
730+
}
731+
728732
if (null !== $definition->getFile()) {
729733
require_once $this->getParameterBag()->resolveValue($definition->getFile());
730734
}

tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ public function testCreateServiceConfigurator()
315315
}
316316
}
317317

318+
/**
319+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
320+
* @expectedException \RuntimeException
321+
*/
322+
public function testCreateSyntheticService()
323+
{
324+
$builder = new ContainerBuilder();
325+
$builder->register('foo', 'FooClass')->setSynthetic(true);
326+
$builder->get('foo');
327+
}
328+
318329
/**
319330
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
320331
*/

0 commit comments

Comments
 (0)
0