Skip to content

Commit

Permalink
[DependencyInjection] fixed the creation of synthetic services in Con…
Browse files Browse the repository at this point in the history
…tainerBuilder
  • Loading branch information
fabpot committed Jan 21, 2013
1 parent 5663820 commit 4119caf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -725,6 +725,10 @@ public function findDefinition($id)
*/
private function createService(Definition $definition, $id)
{
if ($definition->isSynthetic()) {
throw new \RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
}

if (null !== $definition->getFile()) {
require_once $this->getParameterBag()->resolveValue($definition->getFile());
}
Expand Down
Expand Up @@ -315,6 +315,17 @@ public function testCreateServiceConfigurator()
}
}

/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
* @expectedException \RuntimeException
*/
public function testCreateSyntheticService()
{
$builder = new ContainerBuilder();
$builder->register('foo', 'FooClass')->setSynthetic(true);
$builder->get('foo');
}

/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
*/
Expand Down

0 comments on commit 4119caf

Please sign in to comment.