Yaf_Dispatcher::setResponse
Set the response object
説明
public Yaf_Dispatchernull Yaf_Dispatcher::setResponse(Yaf_Response_Abstract $response)
Set the response object used by the dispatcher. This allows using a
custom response implementation instead of the built-in ones.
パラメータ
-
response
-
A Yaf_Response_Abstract instance.
戻り値
Returns the Yaf_Dispatcher object itself on
success, or null if the application is not initialized.
例
例1 Yaf_Dispatcher::setResponse example
<?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();
?>
参考
- Yaf_Dispatcher::getResponse
- Yaf_Dispatcher::setRequest