[DI] fix copying expression providers when analyzing the service graph
This commit is contained in:
parent
4c1e8bd836
commit
246164f748
@ -53,6 +53,9 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
||||
$analyzedContainer = new ContainerBuilder();
|
||||
$analyzedContainer->setAliases($container->getAliases());
|
||||
$analyzedContainer->setDefinitions($container->getDefinitions());
|
||||
foreach ($container->getExpressionLanguageProviders() as $provider) {
|
||||
$analyzedContainer->addExpressionLanguageProvider($provider);
|
||||
}
|
||||
} else {
|
||||
$analyzedContainer = $container;
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
class CustomExpressionLanguageFunctionTest extends TestCase
|
||||
{
|
||||
public function testDump()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('test', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setArguments(array(new Expression('custom_func("foobar")')));
|
||||
|
||||
$container->addExpressionLanguageProvider(new class() implements ExpressionFunctionProviderInterface {
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
ExpressionFunction::fromPhp('strtolower', 'custom_func'),
|
||||
);
|
||||
}
|
||||
});
|
||||
$container->compile();
|
||||
|
||||
$dump = new PhpDumper($container);
|
||||
$dumped = $dump->dump();
|
||||
|
||||
$this->assertContains('strtolower("foobar")', $dumped);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user