The Yaf_Response_Abstract class

Introduction

Yaf_Response_Abstract is the base class of the response object, which carries the headers and the content blocks to be sent to the client. It is instantiated by Yaf_Dispatcher; use Yaf_Dispatcher::getResponse to access it, typically inside controllers, actions or plugins.

The concrete subclasses are Yaf_Response_Http (used in web SAPIs, which actually sends HTTP headers) and Yaf_Response_Cli (used on the command line).

Class synopsis

Yaf_Response_Abstract
class Yaf_Response_Abstract {
/* Constants */
const string Yaf_Response_Abstract::DEFAULT_BODY = "content";
/* Properties */
protected $_header;
protected $_body;
protected $_sendheader;
/* Methods */
public __construct()
public Yaf_Response_Abstractfalsenull appendBody(string $body, string $key = ?)
public Yaf_Response_Abstractfalsenull clearBody(string $key = ?)
public Yaf_Response_Abstractfalsenull clearHeaders()
public mixed getBody(string $key = ?)
public stringarraynull getHeader(string $name = ?)
public Yaf_Response_Abstractfalsenull prependBody(string $body, string $key = ?)
public boolnull response()
public bool setAllHeaders(array $headers)
public Yaf_Response_Abstractfalsenull setBody(string $body, string $key = ?)
public bool setHeader(
    string $name,
    string $value,
    bool $replace = false,
    int $response_code = 0
)
public boolnull setRedirect(string $url)
private string __toString()
}

Properties

_header
The HTTP headers set so far, as an array of header name/value pairs. Only meaningful for Yaf_Response_Http.
_body
The content blocks, keyed by the content key (by default content, i.e. Yaf_Response_Abstract::DEFAULT_BODY).
_sendheader
Whether headers should be sent together with the content. In Yaf_Response_Http it also tracks whether the headers have been sent already.
Table of Contents