Skip to content

Commit

Permalink
Clarifying nested $routes->group() options [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
tangix committed Dec 13, 2020
1 parent 10baac2 commit 4e4aabe
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 4e4aabe

Please sign in to comment.