Skip to content

New #[Route] attribute parameter alias does not work for localized routes #60595

Open
@alcohol

Description

@alcohol

Symfony version(s) affected

7.3.0

Description

I'm trying to use the new alias introduced on the #[Route] attribute in 7.3, but getting unexpected results.

How to reproduce

with configuration

# config/routing.yaml
general:
  resource: '../src/Controller/'
  type: attribute
  prefix:
    nl_NL: /
    nl_BE: /
    fr_FR: /
    fr_BE: /fr
    en_US: /
  host:
    nl_NL: '%nl_host%'
    nl_BE: '%be_host%'
    fr_FR: '%fr_host%'
    fr_BE: '%be_host%'
    en_US: '%en_host%'

using

#[Route(path: [
    'nl_NL' => '/',
    'nl_BE' => '/',
    'fr_FR' => '/',
    'fr_BE' => '/',
    'en_US' => '/',
], name: 'default', methods: ['GET'], alias: ['my-alias'])]

yields Target route "default" for alias "my-alias" does not exist. from the template where i try to generate url(app.current_route)

but using

#[Route(path: '/', name: 'default', methods: ['GET'], alias: ['my-alias'])] 

yields Unable to generate a URL for the named route "my-alias" as such route does not exist. later on in the same template when trying to generate url('my-alias')

Possible Solution

No response

Additional Context

No response

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