« Yaf_Dispatcher::setRequest
Yaf_Dispatcher::setView »

Yaf_Dispatcher::setResponse

(Yaf >=3.2.2)

Yaf_Dispatcher::setResponse — Set the response object

説明

public function Yaf_Dispatcher::setResponse(Yaf_Response_Abstract $response): ?Yaf_Dispatcher

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();
?>

参考

関連キーワード:
Dispatcher   response   setResponse   setRequest   Response   application   Abstract   ApiResponse   setView   used   dispatcher   allows   using   custom   implementation   instead   built-in   ones   instance   itself   success   initialized   example   extends   Http
関連する関数・ページ:
yaf-dispatcher.getresponse   yaf-dispatcher.setrequest   yaf-dispatcher.construct   yaf-dispatcher.setdefaultmodule   yaf-dispatcher.getrequest   yaf-dispatcher.seterrorhandler