8000 Impossible to hook into the DependencyInjection ExpressionLanguage · Issue #13012 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Impossible to hook into the DependencyInjection ExpressionLanguage #13012
Closed
@stof

Description

@stof

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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0