Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] fixed the creation of synthetic services in ContainerBuilder #6827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2013
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
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