RequestHandlerComponent Class Reference

Inheritance diagram for RequestHandlerComponent:

Object

List of all members.


Public Member Functions

 accepts ($type=null)
 beforeRedirect (&$controller, $url)
 getAjaxVersion ()
 getClientIP ()
 getReferrer ()
 initialize (&$controller)
 isAjax ()
 isAtom ()
 isDelete ()
 isFlash ()
 isGet ()
 isMobile ()
 isPost ()
 isPut ()
 isRss ()
 isSSL ()
 isWap ()
 isXml ()
 mapType ($ctype)
 prefers ($type=null)
 renderAs (&$controller, $type)
 requestedWith ($type=null)
 respondAs ($type, $options=array())
 responseType ()
 setContent ($name, $type=null)
 startup (&$controller)

Public Attributes

 $ajaxLayout = 'ajax'
 $enabled = true
 $ext = null
 $params = array()

Detailed Description

Definition at line 41 of file request_handler.php.


Member Function Documentation

RequestHandlerComponent::accepts ( type = null  ) 

Determines which content types the client accepts. Acceptance is based on the file extension parsed by the Router (if present), and by the HTTP_ACCEPT header.

Parameters:
mixed $type Can be null (or no parameter), a string type name, or an array of types
Returns:
mixed If null or no parameter is passed, returns an array of content types the client accepts. If a string is passed, returns true if the client accepts it. If an array is passed, returns true if the client accepts one or more elements in the array. public
See also:
RequestHandlerComponent::setContent()

Definition at line 427 of file request_handler.php.

RequestHandlerComponent::beforeRedirect ( &$  controller,
url 
)

Handles (fakes) redirects for Ajax requests using requestAction()

Parameters:
object $controller A reference to the controller
mixed $url A string or array containing the redirect location public

Definition at line 217 of file request_handler.php.

RequestHandlerComponent::getAjaxVersion (  ) 

Gets Prototype version if call is Ajax, otherwise empty string. The Prototype library sets a special "Prototype version" HTTP header.

Returns:
string Prototype version of component making Ajax call public

Definition at line 347 of file request_handler.php.

RequestHandlerComponent::getClientIP (  ) 

Gets remote client IP

Returns:
string Client IP address public

Definition at line 393 of file request_handler.php.

RequestHandlerComponent::getReferrer (  ) 

Gets the server name from which this request was referred

Returns:
string Server address public

Definition at line 377 of file request_handler.php.

RequestHandlerComponent::initialize ( &$  controller  ) 

Initializes the component, gets a reference to Controller::$parameters, and checks to see if a file extension has been parsed by the Router. If yes, the corresponding content-type is pushed onto the list of accepted content-types as the first item.

Parameters:
object $controller A reference to the controller
See also:
Router::parseExtensions() public

Definition at line 163 of file request_handler.php.

RequestHandlerComponent::isAjax (  ) 

Returns true if the current HTTP request is Ajax, false otherwise

Returns:
boolean True if call is Ajax public

Definition at line 233 of file request_handler.php.

RequestHandlerComponent::isAtom (  ) 

Returns true if the current call accepts an Atom response, false otherwise

Returns:
boolean True if client accepts an RSS response public

Definition at line 278 of file request_handler.php.

RequestHandlerComponent::isDelete (  ) 

Returns true if the current call a DELETE request

Returns:
boolean True if call is a DELETE public

Definition at line 337 of file request_handler.php.

RequestHandlerComponent::isFlash (  ) 

Returns true if the current HTTP request is coming from a Flash-based client

Returns:
boolean True if call is from Flash public

Definition at line 242 of file request_handler.php.

RequestHandlerComponent::isGet (  ) 

Returns true if the current call a GET request

Returns:
boolean True if call is a GET public

Definition at line 328 of file request_handler.php.

RequestHandlerComponent::isMobile (  ) 

Returns true if user agent string matches a mobile web browser, or if the client accepts WAP content.

Returns:
boolean True if user agent is a mobile web browser public

Definition at line 288 of file request_handler.php.

RequestHandlerComponent::isPost (  ) 

Returns true if the current call a POST request

Returns:
boolean True if call is a POST public

Definition at line 310 of file request_handler.php.

RequestHandlerComponent::isPut (  ) 

Returns true if the current call a PUT request

Returns:
boolean True if call is a PUT public

Definition at line 319 of file request_handler.php.

RequestHandlerComponent::isRss (  ) 

Returns true if the current call accepts an RSS response, false otherwise

Returns:
boolean True if client accepts an RSS response public

Definition at line 269 of file request_handler.php.

RequestHandlerComponent::isSSL (  ) 

Returns true if the current request is over HTTPS, false otherwise.

Returns:
bool True if call is over HTTPS public

Definition at line 251 of file request_handler.php.

RequestHandlerComponent::isWap (  ) 

Returns true if the client accepts WAP content

Returns:
bool public

Definition at line 301 of file request_handler.php.

RequestHandlerComponent::isXml (  ) 

Returns true if the current call accepts an XML response, false otherwise

Returns:
boolean True if client accepts an XML response public

Definition at line 260 of file request_handler.php.

RequestHandlerComponent::mapType ( ctype  ) 

Maps a content-type back to an alias

Parameters:
mixed $type Content type
Returns:
mixed Alias public

Definition at line 659 of file request_handler.php.

RequestHandlerComponent::prefers ( type = null  ) 

Determines which content-types the client prefers. If no parameters are given, the content-type that the client most likely prefers is returned. If $type is an array, the first item in the array that the client accepts is returned. Preference is determined primarily by the file extension parsed by the Router if provided, and secondarily by the list of content-types provided in HTTP_ACCEPT.

Parameters:
mixed $type An optional array of 'friendly' content-type names, i.e. 'html', 'xml', 'js', etc.
Returns:
mixed If $type is null or not provided, the first content-type in the list, based on preference, is returned. public
See also:
RequestHandlerComponent::setContent()

Definition at line 500 of file request_handler.php.

RequestHandlerComponent::renderAs ( &$  controller,
type 
)

Sets the layout and template paths for the content type defined by $type.

Parameters:
object $controller A reference to a controller object
string $type Type of response to send (e.g: 'ajax') public
See also:
RequestHandlerComponent::setContent()

RequestHandlerComponent::respondAs()

Definition at line 541 of file request_handler.php.

RequestHandlerComponent::requestedWith ( type = null  ) 

Determines the content type of the data the client has sent (i.e. in a POST request)

Parameters:
mixed $type Can be null (or no parameter), a string type name, or an array of types public

Definition at line 467 of file request_handler.php.

RequestHandlerComponent::respondAs ( type,
options = array() 
)

Sets the response header based on type map index name. If DEBUG is greater than 2, the header is not set.

Parameters:
mixed $type Friendly type name, i.e. 'html' or 'xml', or a full content-type, like 'application/x-shockwave'.
array $options If $type is a friendly type name that is associated with more than one type of content, $index is used to select which content-type to use.
Returns:
boolean Returns false if the friendly type name given in $type does not exist in the type map, or if the Content-type header has already been set by this method. public
See also:
RequestHandlerComponent::setContent()

Definition at line 589 of file request_handler.php.

RequestHandlerComponent::responseType (  ) 

Returns the current response type (Content-type header), or null if none has been set

Returns:
mixed A string content type alias, or raw content type if no alias map exists, otherwise null public

Definition at line 646 of file request_handler.php.

RequestHandlerComponent::setContent ( name,
type = null 
)

Adds/sets the Content-type(s) for the given name. This method allows content-types to be mapped to friendly aliases (or extensions), which allows RequestHandler to automatically respond to requests of that type in the startup method.

Parameters:
string $name The name of the Content-type, i.e. "html", "xml", "css"
mixed $type The Content-type or array of Content-types assigned to the name, i.e. "text/html", or "application/xml" public

Definition at line 364 of file request_handler.php.

RequestHandlerComponent::startup ( &$  controller  ) 

The startup method of the RequestHandler enables several automatic behaviors related to the detection of certain properties of the HTTP request, including:

  • Disabling layout rendering for Ajax requests (based on the HTTP_X_REQUESTED_WITH header)
  • If Router::parseExtensions() is enabled, the layout and template type are switched based on the parsed extension. For example, if controller/action.xml is requested, the view path becomes app/views/controller/xml/action.ctp.
  • If a helper with the same name as the extension exists, it is added to the controller.
  • If the extension is of a type that RequestHandler understands, it will set that Content-type in the response header.
  • If the XML data is POSTed, the data is parsed into an XML object, which is assigned to the $data property of the controller, which can then be saved to a model object.

Parameters:
object $controller A reference to the controller public

Definition at line 185 of file request_handler.php.


Member Data Documentation

RequestHandlerComponent::$ajaxLayout = 'ajax'

Definition at line 49 of file request_handler.php.

RequestHandlerComponent::$enabled = true

Definition at line 56 of file request_handler.php.

RequestHandlerComponent::$ext = null

Definition at line 129 of file request_handler.php.

RequestHandlerComponent::$params = array()

Definition at line 71 of file request_handler.php.


The documentation for this class was generated from the following file: