PHP 8.5.10 Released!

Yaf_Dispatcher::setResponse

(Yaf >=3.2.2)

Yaf_Dispatcher::setResponseSet the response object

Descrizione

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.

Elenco dei parametri

response

A Yaf_Response_Abstract instance.

Valori restituiti

Returns the Yaf_Dispatcher object itself on success, or null if the application is not initialized.

Esempi

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

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top