Skip to content

Commit 5895e96

Browse files
committed
Merge branch '2.0' into 2.1
* 2.0: [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder [Security] PHPDoc in SecurityEvents [FrameworkBundle] fixed Client::doRequest that must call its parent method (closes #6737) [Yaml] fixed ignored text when parsing an inlined mapping or sequence (closes #6786) [Yaml] fixed #6773 [Yaml] fixed #6770 bumped Symfony version to 2.0.23-DEV Conflicts: src/Symfony/Component/DependencyInjection/ContainerBuilder.php src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Yaml/Inline.php src/Symfony/Component/Yaml/Tests/InlineTest.php
2 parents 96e5a16 + 3a819bf commit 5895e96

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

ContainerBuilder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,19 +734,22 @@ public function findDefinition($id)
734734
*
735735
* @throws RuntimeException When the scope is inactive
736736
* @throws RuntimeException When the factory definition is incomplete
737+
* @throws RuntimeException When the service is a synthetic service
737738
* @throws InvalidArgumentException When configure callable is not callable
738739
*/
739740
private function createService(Definition $definition, $id)
740741
{
742+
if ($definition->isSynthetic()) {
743+
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
744+
}
745+
741746
$parameterBag = $this->getParameterBag();
742747

743748
if (null !== $definition->getFile()) {
744749
require_once $parameterBag->resolveValue($definition->getFile());
745750
}
746751

747-
$arguments = $this->resolveServices(
748-
$parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments()))
749-
);
752+
$arguments = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())));
750753

751754
if (null !== $definition->getFactoryMethod()) {
752755
if (null !== $definition->getFactoryClass()) {

Tests/ContainerBuilderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ public function testCreateServiceConfigurator()
319319
}
320320
}
321321

322+
/**
323+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
324+
* @expectedException \RuntimeException
325+
*/
326+
public function testCreateSyntheticService()
327+
{
328+
$builder = new ContainerBuilder();
329+
$builder->register('foo', 'FooClass')->setSynthetic(true);
330+
$builder->get('foo');
331+
}
332+
322333
/**
323334
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
324335
*/

0 commit comments

Comments
 (0)