[DI] Fixed custom services definition BC break introduced in ec7e70fb…
This commit is contained in:
parent
30d161c0ae
commit
7a5e11eb12
@ -840,8 +840,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
*/
|
*/
|
||||||
public function createService(Definition $definition, $id, $tryProxy = true)
|
public function createService(Definition $definition, $id, $tryProxy = true)
|
||||||
{
|
{
|
||||||
if ('Symfony\Component\DependencyInjection\Definition' !== get_class($definition)) {
|
if ($definition instanceof DefinitionDecorator) {
|
||||||
throw new RuntimeException(sprintf('Constructing service "%s" from a %s is not supported at build time.', $id, get_class($definition)));
|
throw new RuntimeException(sprintf('Constructing decorated service "%s" from a %s is not supported at build time.', $id, get_class($definition)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($definition->isSynthetic()) {
|
if ($definition->isSynthetic()) {
|
||||||
|
@ -29,6 +29,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
use Symfony\Component\DependencyInjection\Scope;
|
use Symfony\Component\DependencyInjection\Scope;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition;
|
||||||
use Symfony\Component\ExpressionLanguage\Expression;
|
use Symfony\Component\ExpressionLanguage\Expression;
|
||||||
|
|
||||||
class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -407,7 +408,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||||
* @expectedExceptionMessage Constructing service "foo" from a Symfony\Component\DependencyInjection\DefinitionDecorator is not supported at build time.
|
* @expectedExceptionMessage Constructing decorated service "foo" from a Symfony\Component\DependencyInjection\DefinitionDecorator is not supported at build time.
|
||||||
*/
|
*/
|
||||||
public function testResolveServicesWithDecoratedDefinition()
|
public function testResolveServicesWithDecoratedDefinition()
|
||||||
{
|
{
|
||||||
@ -419,6 +420,14 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$builder->get('foo');
|
$builder->get('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testResolveServicesWithCustomDefinitionClass()
|
||||||
|
{
|
||||||
|
$builder = new ContainerBuilder();
|
||||||
|
$builder->setDefinition('foo', new CustomDefinition('stdClass'));
|
||||||
|
|
||||||
|
$this->assertInstanceOf('stdClass', $builder->get('foo'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testMerge()
|
public function testMerge()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
|
$container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
|
||||||
|
class CustomDefinition extends Definition
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user