Class ActionDispatcher
This class provides compatibility with dispatcher filters and interacting with the controller layers.
Long term this should just be the controller dispatcher, but for now it will do a bit more than that.
Properties summary
- $_eventClass protected
string
Default class name for new event objects.
- $_eventManager protected
\Cake\Event\EventManagerInterface|\Cake\Event\EventManager
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
- $factory protected
\Cake\Http\ControllerFactory
Controller factory instance.
- $filters protected
\Cake\Event\EventListenerInterface[]
Attached routing filters
Method Summary
Method Detail
__construct() public
__construct(mixed $factory, mixed $eventManager, array $filters)
Constructor
Parameters
-
\Cake\Http\ControllerFactory|null
$factory optional A controller factory instance.
-
\Cake\Event\EventManager|null
$eventManager optional An event manager if you want to inject one.
-
\Cake\Event\EventListenerInterface[]
$filters optional The list of filters to include.
_invoke() protected
_invoke(\Cake\Controller\Controller $controller)
Invoke a controller's action and wrapping methods.
Parameters
-
\Cake\Controller\Controller
$controller The controller to invoke.
Returns
\Cake\Http\Response
The response
Throws
LogicException
If the controller action returns a non-response value.
addFilter() public
addFilter(\Cake\Event\EventListenerInterface $filter)
Add a filter to this dispatcher.
The added filter will be attached to the event manager used by this dispatcher.
Parameters
-
\Cake\Event\EventListenerInterface
$filter The filter to connect. Can be any EventListenerInterface. Typically an instance of \Cake\Routing\DispatcherFilter.
dispatch() public
dispatch(\Cake\Http\ServerRequest $request, \Cake\Http\Response $response)
Dispatches a Request & Response
Parameters
-
\Cake\Http\ServerRequest
$request The request to dispatch.
-
\Cake\Http\Response
$response The response to dispatch.
Returns
\Cake\Http\Response
A modified/replaced response.
Throws
ReflectionException
dispatchEvent() public
dispatchEvent(mixed $name, mixed $data, mixed $subject)
Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
-
string
$name Name of the event.
-
array|null
$data optional Any value you wish to be transported with this event to it can be read by listeners.
-
object|null
$subject optional The object that this event applies to ($this by default).
Returns
\Cake\Event\Event
eventManager() public
eventManager(\Cake\Event\EventManager $eventManager)
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
-
\Cake\Event\EventManager|null
$eventManager optional the eventManager to set
Returns
\Cake\Event\EventManager
getEventManager() public
getEventManager()
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Returns
\Cake\Event\EventManager
getFilters() public
getFilters()
Get the connected filters.
Returns
array
setEventManager() public
setEventManager(\Cake\Event\EventManager $eventManager)
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
-
\Cake\Event\EventManager
$eventManager the eventManager to set
Returns
$this
Property Detail
$_eventClass protected
Default class name for new event objects.
Type
string
$_eventManager protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
\Cake\Event\EventManagerInterface|\Cake\Event\EventManager
$factory protected
Controller factory instance.
Type
\Cake\Http\ControllerFactory
$filters protected
Attached routing filters
Type
\Cake\Event\EventListenerInterface[]
© 2005–present 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/3.9/class-Cake.Http.ActionDispatcher.html