Skip to content

Commit

Permalink
Merge pull request #3985 from tangix/routes-doc-2
Browse files Browse the repository at this point in the history
Clarifying nested $routes->group() options [ci skip]
  • Loading branch information
MGatner authored Dec 13, 2020
2 parents 539fa41 + 4e4aabe commit f3389d1
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,6 @@ extensive set of routes that all share the opening string, like when building an
});

This would prefix the 'users' and 'blog" URIs with "admin", handling URLs like ``/admin/users`` and ``/admin/blog``.
It is possible to nest groups within groups for finer organization if you need it::

$routes->group('admin', function($routes)
{
$routes->group('users', function($routes)
{
$routes->add('list', 'Admin\Users::list');
});

});

This would handle the URL at ``admin/users/list``.

If you need to assign options to a group, like a `namespace <#assigning-namespace>`_, do it before the callback::

Expand All @@ -255,6 +243,20 @@ run the filter before or after the controller. This is especially handy during a

The value for the filter must match one of the aliases defined within ``app/Config/Filters.php``.

It is possible to nest groups within groups for finer organization if you need it::

$routes->group('admin', function($routes)
{
$routes->group('users', function($routes)
{
$routes->add('list', 'Admin\Users::list');
});

});

This would handle the URL at ``admin/users/list``. Note that options passed to the outer ``group()`` (for example
``namespace`` and ``filter``) are not merged with the inner ``group()`` options.

At some point, you may want to group routes for the purpose of applying filters or other route
config options like namespace, subdomain, etc. Without necessarily needing to add a prefix to the group, you can pass
an empty string in place of the prefix and the routes in the group will be routed as though the group never existed but with the
Expand Down

0 comments on commit f3389d1

Please sign in to comment.