Dispatcher converts Requests into controller actions. It uses the dispatched Request to locate and load the correct controller. If found, the requested action is called on the controller.
__construct( string $base false )
Constructor.
$base
optional false App.base
to Configure._attachFilters( CakeEventManager $manager )
Attaches all event listeners for this dispatcher instance. Loads the dispatcher filters from the configured locations.
CakeEventManager
$manager
MissingDispatcherFilterException
_getController( CakeRequest $request , CakeResponse $response )
Get controller to use, either plugin controller or application controller
CakeRequest
$request
CakeResponse
$response
mixed
_invoke( Controller $controller , CakeRequest $request )
Initializes the components and models a controller will be using. Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output. Otherwise the return value of the controller action are returned.
Controller
$controller
CakeRequest
$request
CakeResponse
_loadController( CakeRequest $request )
Load controller and return controller class name
CakeRequest
$request
string|boolean
dispatch( CakeRequest $request , CakeResponse $response , array $additionalParams array() )
Dispatches and invokes given Request, handing over control to the involved controller. If the controller is set to autoRender, via Controller::$autoRender, then Dispatcher will render the view.
Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you want controller methods to be public and in-accessible by URL, then prefix them with a _
. For example public function _loadPosts() { }
would not be accessible via URL. Private and protected methods are also not accessible via URL.
If no controller of given name can be found, invoke() will throw an exception. If the controller is found, and the action is not found an exception will be thrown.
CakeRequest
$request
CakeResponse
$response
$additionalParams
optional array() string|null
$request['return']
is set then it returns response body, null otherwiseMissingControllerException
getEventManager( )
Returns the CakeEventManager instance or creates one if none was created. Attaches the default listeners and filters
CakeEventManager
implementedEvents( )
Returns the list of events this object listens to.
array
CakeEventListener::implementedEvents()
parseParams( CakeEvent $event )
Applies Routing and additionalParameters to the request to be dispatched. If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
CakeEvent
$event
© 2005–2016 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.
http://api.cakephp.org/2.7/class-Dispatcher.html