Closed
Description
Symfony 2.6 added the ExpressionFunctionProviderInterface to allow register your own functions in expressions. However this hook is not usable for DI expressions, because Symfony builds an ExpressionLanguage for them in 2 different places, and one of them is not accessible.
- for services created dynamically from the ContainerBuilder, the providers registered in the ContainerBuilder are used. This is accessible as bundles can register a provider in their
build()
method - when dumping the container, the providers registered in the PhpDumper are used. But providers registered in the ContainerBuilder are not automatically copied there, and the PhpDumper is instantiated by the Kernel without giving access to bundles.
Having 2 places to register the providers is tricky, because you will get an unexpected behavior if you don't register the same providers in both places (expressions being valid in one place but not in the other), meaning the hook is currently unusable.
I suggest that the PhpDumper automatically registers the providers set in the ContainerBuilder, and that we deprecate the possibility to register providers in the PhpDumper itself. What do you think ?