Controller/Response/Abstract.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Controller  
Version
$Id$  

\Zend_Controller_Response_Abstract

Package: Zend_Controller\Response
Zend_Controller_Response_Abstract
Base class for Zend_Controller responses
Children
\Zend_Controller_Response_Http
\Zend_Controller_Response_Cli
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedarray $_body = array()
Body content
Default valuearray()Details
Type
array
>VPropertyprotected\Exception $_exceptions = array()
Exception stack
Default valuearray()Details
Type
\Exception
>VPropertyprotectedarray $_headers = array()
Array of headers. Each header is an array with keys 'name' and 'value'
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_headersRaw = array()
Array of raw headers. Each header is a single string, the entire header to emit
Default valuearray()Details
Type
array
>VPropertyprotectedint $_httpResponseCode = 200
HTTP response code to use in headers
Default value200Details
Type
int
>VPropertyprotectedboolean $_isRedirect = false
Flag; is this response a redirect?
Default valuefalseDetails
Type
boolean
>VPropertyprotectedboolean $_renderExceptions = false
Whether or not to render exceptions; off by default
Default valuefalseDetails
Type
boolean
>VPropertypublicboolean $headersSentThrowsException = true
Flag; if true, when header operations are called after headers have been sent, an exception will be raised; otherwise, processing will continue as normal. Defaults to true.
Default valuetrueDetails
Type
boolean
See
 

Methods

methodpublic__toString() : string

Magic __toString functionality

Proxies to {@link sendResponse()} and returns response value as string using output buffering.
Returns
TypeDescription
string
methodprotected_normalizeHeader(string $name) : string

Normalize a header name

Normalizes a header name to X-Capitalized-Names
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodpublicappend(string $name, string $content) : \Zend_Controller_Response_Abstract

Append a named body segment to the body content array

If segment already exists, replaces with $content and places at end of array.
Parameters
NameTypeDescription
$namestring
$contentstring
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicappendBody(string $content, null | string $name = null) : \Zend_Controller_Response_Abstract

Append content to the body content

Parameters
NameTypeDescription
$contentstring
$namenull | string
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpubliccanSendHeaders(boolean $throw = false) : boolean

Can we send headers?

Parameters
NameTypeDescription
$throwboolean

Whether or not to throw an exception if headers have been sent; defaults to false

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Controller_Response_Exception
methodpublicclearAllHeaders() : \Zend_Controller_Response_Abstract

Clear all headers, normal and raw

methodpublicclearBody(string $name = null) : boolean

Clear body array

With no arguments, clears the entire body array. Given a $name, clears just that named segment; if no segment matching $name exists, returns false to indicate an error.
Parameters
NameTypeDescription
$namestring

Named segment to clear

Returns
TypeDescription
boolean
methodpublicclearHeader(string $name) : \Zend_Controller_Response_Abstract

Clears the specified HTTP header

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicclearHeaders() : \Zend_Controller_Response_Abstract

Clear headers

methodpublicclearRawHeader(string $headerRaw) : \Zend_Controller_Response_Abstract

Clears the specified raw HTTP header

Parameters
NameTypeDescription
$headerRawstring
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicclearRawHeaders() : \Zend_Controller_Response_Abstract

Clear all {@link setRawHeader() raw HTTP headers}

methodpublicgetBody(boolean $spec = false) : string | array | null

Return the body content

If $spec is false, returns the concatenated values of the body content array. If $spec is boolean true, returns the body content array. If $spec is a string and matches a named segment, returns the contents of that segment; otherwise, returns null.
Parameters
NameTypeDescription
$specboolean
Returns
TypeDescription
string | array | null
methodpublicgetException() : array

Retrieve the exception stack

Returns
TypeDescription
array
methodpublicgetExceptionByCode(mixed $code) : void

Retrieve all exceptions of a given code

Parameters
NameTypeDescription
$codemixed
methodpublicgetExceptionByMessage(string $message) : false | array

Retrieve all exceptions of a given message

Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
false | array
methodpublicgetExceptionByType(string $type) : false | array

Retrieve all exceptions of a given type

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
false | array
methodpublicgetHeaders() : array

Return array of headers; see {@link $_headers} for format

Returns
TypeDescription
array
methodpublicgetHttpResponseCode() : int

Retrieve HTTP response code

Returns
TypeDescription
int
methodpublicgetRawHeaders() : array

Retrieve all {@link setRawHeader() raw HTTP headers}

Returns
TypeDescription
array
methodpublichasExceptionOfCode(int $code) : boolean

Does the response object contain an exception with a given code?

Parameters
NameTypeDescription
$codeint
Returns
TypeDescription
boolean
methodpublichasExceptionOfMessage(string $message) : boolean

Does the response object contain an exception with a given message?

Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
boolean
methodpublichasExceptionOfType(string $type) : boolean

Does the response object contain an exception of a given type?

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
boolean
methodpublicinsert(string $name, string $content, string $parent = null, boolean $before = false) : \Zend_Controller_Response_Abstract

Insert a named segment into the body content array

Parameters
NameTypeDescription
$namestring
$contentstring
$parentstring
$beforeboolean

Whether to insert the new segment before or after the parent. Defaults to false (after)

Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicisException() : boolean

Has an exception been registered with the response?

Returns
TypeDescription
boolean
methodpublicisRedirect() : boolean

Is this a redirect?

Returns
TypeDescription
boolean
methodpublicoutputBody() : void

Echo the body segments

methodpublicprepend(string $name, string $content) : void

Prepend a named body segment to the body content array

If segment already exists, replaces with $content and places at top of array.
Parameters
NameTypeDescription
$namestring
$contentstring
methodpublicrenderExceptions(boolean $flag = null) : boolean

Whether or not to render exceptions (off by default)

If called with no arguments or a null argument, returns the value of the flag; otherwise, sets it and returns the current value.
Parameters
NameTypeDescription
$flagboolean

Optional

Returns
TypeDescription
boolean
methodpublicsendHeaders() : \Zend_Controller_Response_Abstract

Send all headers

Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code} has been specified, it is sent with the first header.
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsendResponse() : void

Send the response, including all headers, rendering exceptions if so requested.

methodpublicsetBody(string $content, null | string $name = null) : \Zend_Controller_Response_Abstract

Set body content

If $name is not passed, or is not a string, resets the entire body and sets the 'default' key to $content. If $name is a string, sets the named segment in the body array to $content.
Parameters
NameTypeDescription
$contentstring
$namenull | string
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsetException(\Exception $e) : \Zend_Controller_Response_Abstract

Register an exception with the response

Parameters
NameTypeDescription
$e\Exception
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsetHeader(string $name, string $value, boolean $replace = false) : \Zend_Controller_Response_Abstract

Set a header

If $replace is true, replaces any headers already defined with that $name.
Parameters
NameTypeDescription
$namestring
$valuestring
$replaceboolean
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsetHttpResponseCode(int $code) : \Zend_Controller_Response_Abstract

Set HTTP response code to use with headers

Parameters
NameTypeDescription
$codeint
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsetRawHeader(string $value) : \Zend_Controller_Response_Abstract

Set raw HTTP header

Allows setting non key => value headers, such as status codes
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Response_Abstract
methodpublicsetRedirect(string $url, int $code = 302) : \Zend_Controller_Response_Abstract

Set redirect URL

Sets Location header and response code. Forces replacement of any prior redirects.
Parameters
NameTypeDescription
$urlstring
$codeint
Returns
TypeDescription
\Zend_Controller_Response_Abstract
Documentation was generated by phpDocumentor 2.2.0 .