Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Routing] Do not letRouteCollection overrideRoute conditions #53171

Open
@mbuliard

Description

@mbuliard

Description

Hi,

TLDR: General Condition defined in YAML/XML collections overrides specific condition defined in attribute.

I have a trouble with route conditions on a project I'm working on.
Routes are loading via a mix of YAML and Attributes :

api:resource:../../src/Controller/type:annotationcondition:"%general_condition%"
#[Route(path:"my/route", condition:"specific condition")]finalclass MyController {   ...}

My trouble is that the specific condition, defined by attribute, is overrided by the general condition, defined via YAML.
Looking into the component, I found out that when the YamlFileLoader sets the condition on the RouteCollection, the RouteCollection overrides any previous condition.
I find it disturbing that a general condition overrides a specific condition.

publicfunctionsetCondition(?string$condition){foreach ($this->routesas$route) {$route->setCondition($condition);    }}

Propositions

  1. Make specific overrides general, but I fear it is a BC since previously enforced general condition would not be any more.
publicfunctionsetCondition(?string$condition){foreach ($this->routesas$route) {if ('' ===$route->getCondition()) {$route->setCondition($condition);        }    }}
  1. Combine conditions. I don't think of it as a BC since one cannot expect its attribute condition tonot work.
publicfunctionsetCondition(?string$condition){foreach ($this->routesas$route) {if ('' ===$route->getCondition()) {$route->setCondition($condition);        }else {$route->setCondition('(' .$route->getCondition .') and (' .$condition .')');        }    }}

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp