Yaf_Dispatcher::dispatch
(Yaf >=1.0.0)
Dispatch a request
Description
This method does the heavy work of the Yaf_Dispatcher. It takes a request object.
The dispatch process has three distinct events:
- Routing
- Dispatching
- Response
Routing takes place exactly once, using the values in the request object when Yaf_Dispatcher::dispatch is called. Dispatching takes place in a loop; a request may either indicate multiple actions to dispatch, or the controller or a plugin may reset the request object to force additional actions to dispatch (see Yaf_Plugin_Abstract). When all is done, the Yaf_Dispatcher returns a response.
Parameters
requestA
Yaf_Request_Abstractinstance to dispatch.
Return Values
The Yaf_Response_Abstract instance on success, false on failure, or null if the application is not initialized.
Examples
Yaf_Dispatcher::dispatch example
<?php
$app = new Yaf_Application(dirname(__FILE__) . "/conf/application.ini");
$app->bootstrap();
// Build a request pointing at ProductController::detailAction and
// dispatch it manually.
$request = new Yaf_Request_Http("/product/detail/id/42");
$response = Yaf_Dispatcher::getInstance()->dispatch($request);
if ($response instanceof Yaf_Response_Abstract) {
$response->response();
}
?>See Also
Yaf_Application::runYaf_Plugin_Abstract