Skip to content

Commit

Permalink
Filter in the router supports after. Fixes #1315
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbangda committed Oct 23, 2018
1 parent 5b27a44 commit 01140a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,11 @@ protected function handleRequest(RouteCollectionInterface $routes = null, $cache
$filters = Services::filters();

// If any filters were specified within the routes file,
// we need to ensure it's active for the current request (before only)
// we need to ensure it's active for the current request
if (! is_null($routeFilter))
{
$filters->enableFilter($routeFilter, 'before');
$filters->enableFilter($routeFilter, 'after');
}

$uri = $this->request instanceof CLIRequest ? $this->request->getPath() : $this->request->uri->getPath();
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ If you need to assign options to a group, like a `namespace <#assigning-namespac

This would handle a resource route to the ``App\API\v1\Users`` controller with the ``/api/users`` URI.

You can also use ensure that a specific `filter </general/filters>`_ gets ran for a group of routes. This will always
run the filter before the controller. This is especially handy during authentication::
You can also use ensure that a specific `filter </incoming/filters.html>`_ gets ran for a group of routes. This will always
run the filter before or after the controller. This is especially handy during authentication or api logging::

$routes->group('api', ['filter' => 'api-auth'], function($routes)
{
Expand Down

0 comments on commit 01140a2

Please sign in to comment.