Class DispatcherFilter
This abstract class represents a filter to be applied to a dispatcher cycle. It acts as as 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.
- DispatcherFilter implements CakeEventListener
Direct Subclasses
Package: Cake\Routing
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Routing/DispatcherFilter.php
Properties summary
-
$priority
publicDefault priority for all methods in this filterinteger
-
$settings
publicSettings for this filterarray
Method Summary
- __construct() publicConstructor.
- afterDispatch() public
Method called after the controller served a request and generated a response. It is possible to alter the response object at this point as it is not sent to the client yet.
- beforeDispatch() public
Method called before the controller is instantiated and called to serve a request. If used with default priority, it will be called after the Router has parsed the URL and set the routing params into the request object.
- implementedEvents() public
Returns the list of events this filter listens to. Dispatcher notifies 2 different events
Dispatcher.before
andDispatcher.after
. By default this class will attachpreDispatch
andpostDispatch
method respectively.
Method Detail
__construct()source public
__construct( array $settings array() )
Constructor.
Parameters
- array
$settings
optional array() - Configuration settings for the filter.
afterDispatch()source public
afterDispatch( CakeEvent $event )
Method called after the controller served a request and generated a response. It is possible to alter the response object at this point as it is not sent to the client yet.
If false is returned, the event will be stopped and no more listeners will be notified. Alternatively you can call $event->stopPropagation()
to achieve the same result.
Parameters
-
CakeEvent
$event
container object having the
request
andresponse
keys in the data property.
Returns
mixedboolean to stop the event dispatching or null to continue
beforeDispatch()source public
beforeDispatch( CakeEvent $event )
Method called before the controller is instantiated and called to serve a request. If used with default priority, it will be called after the Router has parsed the URL and set the routing params into the request object.
If a CakeResponse object instance is returned, it will be served at the end of the event cycle, not calling any controller as a result. This will also have the effect of not calling the after event in the dispatcher.
If false is returned, the event will be stopped and no more listeners will be notified. Alternatively you can call $event->stopPropagation()
to achieve the same result.
Parameters
-
CakeEvent
$event
container object having the
request
,response
andadditionalParams
keys in the data property.
Returns
CakeResponse
|booleanimplementedEvents()source public
implementedEvents( )
Returns the list of events this filter listens to. Dispatcher notifies 2 different events Dispatcher.before
and Dispatcher.after
. By default this class will attach preDispatch
and postDispatch
method respectively.
Override this method at will to only listen to the events you are interested in.
Returns
arrayImplementation of
CakeEventListener::implementedEvents()
Properties detail
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-DispatcherFilter.html