Skip to content

Support !php/const in routing yaml #31356

@timwsuqld

Description

@timwsuqld

Description
Currently we support !php/const for constants in service files. It would be good to be able to use them in routing files as well.

Example
We have some routes that rely on constants, we currently have to put them in to a parameter and then we can use them in our routes

Currently we have:

staff_dashboard:
    host: '%domain_staff%'
    path: /dashboards/default/

Plus a parameter for domain_staff which actually comes from a constant DOMAIN_STAFF.

We could do away with the parameter and just have:

staff_dashboard:
    host: !php/const DOMAIN_STAFF
    path: /dashboards/default/

Fix
In YamlFileLoader.php we change

$parsedConfig = $this->yamlParser->parseFile($path);

to

$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);

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