Updated: Comment #0
Follow-up from #1921544-82: Create a Current Path Condition.
@catch said
Users won't have access to the route names - but the whole point of having a router + generator is being able to move routes around without path-specific code breaking. I think this could use more discussion - i.e. should we open a follow-up to add a route condition?
Problem/Motivation
We should be moving towards matching the route and params instead of the path. The problem is that users maybe will not have access to the route names.
Proposed resolution
Create route and params condition and replace current path condition.
Remaining tasks
Are we only going to create route and params condition? or are we going to replace path condition with route and params condition? This needs more discussion.
User interface changes
Route and params condition is going to replace current path condition.
API changes
Route and params condition is going to replace current path condition.
Related Issues
#1921544: Create a Current Path Condition
#1743686: Condition Plugin System
Comment | File | Size | Author |
---|---|---|---|
#20 | 2071553-route-condition-20.patch | 3.56 KB | jian he |
#20 | interdiff.txt | 3.09 KB | jian he |
Comments
Comment #1
jibranComment #2
kim.pepperComment #3
kim.pepperHere's a very simple implementation that only works with route names, and not route parameters.
Comment #4
kim.pepperDiscussed with @tim.plunkett in IRC and agreed that we should only put one route.
I've also added a form for said route.
Comment #5
kim.pepperOops. Copy and paste error.
Comment #6
dawehnerCan't we do something similar as menu links do: store route names/parameters internally but use paths for the UI?
Comment #7
kim.pepperI guess so? The menu link code looks pretty complicated, and I assume we'd be duplicating some of this.
Comment #8
tim.plunkettDo we really want to do that?
If someone alters the path used by a given route name, should the condition follow that? Or begin to fail because the path no longer matches?
Also that would overlap with the path condition...
Comment #9
dawehnerWell, we do follow changes to the path for example on menu links already.
I could though see usecases for both to be honest. IN d7 people often used path aliases for this which lead to a couple of problems when removing them or changing them.
Comment #10
kim.pepperComment #13
dawehnerWe should use the route match now.
Comment #14
EclipseGc CreditAttribution: EclipseGc commentedThis seems like it should probably become CTools domain for the forseeable future.
Eclipse
Comment #15
EclipseGc CreditAttribution: EclipseGc commentedwrong ctools...
Comment #16
jian he CreditAttribution: jian he commentedThis one will working :)
Comment #17
tim.plunkett$form['route']
Comment #18
jian he CreditAttribution: jian he commentedFixed configuration form.
Comment #19
joshi.rohit100I guess it is request matcher
Comment #20
jian he CreditAttribution: jian he commented1. Fixed the document mentioned at #19
2. Added the schema definition
3. Rename the route configuration param into route_name
Comment #21
EclipseGc CreditAttribution: EclipseGc commentedAnyone opposed to an autocomplete for the route name? My concern would be around security.
Eclipse
Comment #22
EclipseGc CreditAttribution: EclipseGc commentedAlso, looking at this again, I'm not sure a route by name condition is all that useful. Maybe it is, but it needs to be multivalue because multiple routes can exist on the same path. Also you might be interested in more than just parameters. I could see a use case for request method just off the top of my head. Whatever the case this will definitely need some serious tests and I'd like to hear more about the benefits/detriments of path vs route in our new world of multiple routes per path.
Eclipse
Comment #23
EclipseGc CreditAttribution: EclipseGc commentedOn further thought I've decided to close this issue. If someone feels strongly that this should be a thing, re-open it and let's discuss.
Eclipse
Comment #24
tim.plunkettComment #25
jibranI think we are going in a wrong direction here. We should change the scope of the issue.
\Drupal\system\Plugin\Condition\RequestPath
is still matching the path. The UI should remain the same but we should stores routes instead of paths and we should match route name instead of a path.