Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DependencyInjection] fixed the creation of synthetic services in Con…
…tainerBuilder
  • Loading branch information
fabpot committed Jan 21, 2013
commit 4119cafdbe9bd06ae45d23aafcfb83b50b34b0a8
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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