-
Notifications
You must be signed in to change notification settings - Fork 48
Document new priority key for plugin route definitions #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,7 @@ Each firewall accepts an array of defined routes. Each key, the route's name, mu | |
|
|
||
| .. warning:: Each route's name must be unique across all bundles and firewalls and paths must be unique within the same firewall. | ||
|
|
||
| .. warning:: Order of routes matters as Symfony uses the first route that matches the URL. | ||
| .. warning:: Order of routes matters as Symfony uses the first route that matches the URL. Set a route's ``priority`` to control this order. | ||
|
|
||
| Route definitions | ||
| ================= | ||
|
|
@@ -179,6 +179,10 @@ Route definitions define the route's method, path, controller, parameters, and o | |
| - no | ||
| - boolean | ||
| - If the firewall is ``api``, setting this to ``TRUE`` automatically registers GET, POST, PUT, PATCH, and DELETE API endpoints for single and batch handling of entities. | ||
| * - ``priority`` | ||
| - no | ||
| - integer | ||
| - Sets the order in which Mautic registers the route, relative to other routes. Symfony matches higher-priority routes first, and routes with equal priority keep their definition order. Use this to resolve match-order conflicts between overlapping paths. Defaults to ``0`` when omitted. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CoreSubscriber::addRouteToCollection() reads $details['priority'], casts to int, defaults to 0 when absent, and passes it as the third ($priority) argument to Symfony RouteCollection::add(). This method is invoked from onBuildRoute() for every bundle returned by BundleHelper::getMauticBundles(true), which includes plugin bundles, so the priority key applies to plugin-declared routes as documented. |
||
|
|
||
| Special routing parameters | ||
| -------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony routing docs: "Routes with higher priority are sorted before routes with lower priority. The default value when it is not defined is 0." Symfony evaluates routes in the order they are defined when priority is otherwise equal. Confirmed against symfony/routing RouteCollection::all()/add() source: ties are broken by original insertion (definition) order via a stable uksort fallback on $keysOrder.
Source: https://symfony.com/doc/current/routing.html#routing-priority-parameter