Skip to content

[Routing] Route Name Prefixing #19612

@chrisguitarguy

Description

@chrisguitarguy

This is a feature request/suggestion.

It would pretty nifty to be able to prefix route IDs/names on import. The idea is that the same routing resource could be imported multiple times and generate unique route names.

For example: if you have a typical form login on one host for a UI and a stateless API token authentication on another. You might want to share the same routing config for your API between the two hosts.

<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/routing
        http://symfony.com/schema/routing/routing-1.0.xsd">

    <!-- ... -->

    <import resource="@AppBundle/Resources/config/api.xml" prefix="/api" host="%uihost%">
        <default key="_format">json</default>
    </import>

    <import resource="@AppBundle/Resources/config/api.xml" host="%apihost%">
        <default key="_format">json</default>
    </import>

</routes>

Right now this can't be done. The second import overrides all the named routes in the first. Ideally I'd like to be able to do this...

<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/routing
        http://symfony.com/schema/routing/routing-1.0.xsd">

    <!-- ... -->

    <import resource="@AppBundle/Resources/config/api.xml" prefix="/api" host="%uihost%">
        <default key="_format">json</default>
    </import>

    <import resource="@AppBundle/Resources/config/api.xml" host="%apihost%" idprefix="api.">
        <default key="_format">json</default>
    </import>

</routes>

All routes in the second import would get the ID api.{original_id_attribute_value}.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions