Yaf_Dispatcher::setResponse
PHP function
Edit on GitHub ✎
(Yaf >=3.2.2)
Set the response object
Description
Yaf_Dispatcher::setResponse(Yaf_Response_Abstract $response): Yaf_Dispatcher|null
Set the response object used by the dispatcher. This allows using a custom response implementation instead of the built-in ones.
Parameters
responseA
Yaf_Response_Abstractinstance.
Return Values
Returns the Yaf_Dispatcher object itself on success, or null if the application is not initialized.
Examples
Yaf_Dispatcher::setResponse example
php
<?php
class ApiResponse extends Yaf_Response_Http
{
public function response()
{
header("Content-Type: application/json");
parent::response();
}
}
$app = new Yaf_Application(dirname(__FILE__) . "/conf/application.ini");
Yaf_Dispatcher::getInstance()->setResponse(new ApiResponse());
$app->run();
?>See Also
Yaf_Dispatcher::getResponseYaf_Dispatcher::setRequest