Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/plugins/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor Author

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


Route definitions
=================
Expand Down Expand Up @@ -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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Source: https://github.com/mautic/mautic/blob/b6f8c72f14509573ca7ed719b811f8ba210b7d9c/app/bundles/CoreBundle/EventListener/CoreSubscriber.php#L292-L294


Special routing parameters
--------------------------
Expand Down
Loading