merged branch fabpot/synthetic-service-fix (PR #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
👍
This commit is contained in:
commit
115114b0dc
@ -725,6 +725,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
@ -315,6 +315,17 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user