DispatcherFilter (class)
Class DispatcherFilter
This abstract class represents a filter to be applied to a dispatcher cycle. It acts as an event listener with the ability to alter the request or response as needed before it is handled by a controller or after the response body has already been built.
Subclasses of this class use a class naming convention having a Filter
suffix.
Limiting filters to specific paths
By using the for
option you can limit with request paths a filter is applied to. Both the before and after event will have the same conditions applied to them. For example, if you only wanted a filter applied to blog requests you could do:
$filter = new BlogFilter(['for' => '/blog']);
When the above filter is connected to a dispatcher it will only fire its beforeDispatch
and afterDispatch
methods on requests that start with /blog
.
The for co