ZenMagick 0.9.10


org.zenmagick.mvc\ZMRequest
mvc\ZMRequest.php at line 33

Class ZMRequest

ZMObject
└─ZMRequest

public class ZMRequest
extends ZMObject

A request wrapper.

NOTE: For the time of transition between static and instance usage of request methods this will have a temp. name of ZMRequest.

Author:
DerManoMann

Constant Summary
final static str

DEFAULT_REQUEST_ID

Default paramter name containing the request id.

final static str

SESSION_TOKEN_NAME

Name of the session token form field and also the name in the session.

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct(array parameter)

Create new instance.

string

absoluteURL(string url, boolean full, boolean secure)

Convert a given relative URL into an absolute one.

void

closeSession()

Close session if required.

string

getContext()

Get the URL context for this request.

ZMController

getController()

Get the controller for this request.

string

getFollowUpUrl(boolean clear)

Check if a follow up url exists that should be loaded (after a login).

string

getHostname()

Get the hostname for this request.

string

getMethod()

Get the request method.

mixed

getParameter(string name, mixed default, boolean sanitize)

Generic access method for request parameter.

array

getParameterMap(boolean sanitize)

Get the complete parameter map.

string

getPort()

Get the port for this request.

string

getProtocol()

Get the protocol used.

string

getQueryString()

Get the full query string.

string

getRequestId()

Get the request id.

string

getRequestIdKey()

Get the name of the request parameter that contains the request id.

array

getSeoRewriter()

Get a list of ZMSeoRewriter instances for SEO urls.

ZMSession

getSession()

Get the current session.

string

getTemplatePath()

Get the template path.

ZMToolbox

getToolbox()

Get the toolbox for this request.

string

getUri()

Get the uri for this request.

mixed

getUser()

Get the user (if any) for authentication.

string

getWebPath()

Get the web path.

static void

instance()

Get instance.

boolean

isSecure()

Checks if the current request is secure or note.

void

redirect(string url, int status)

Redirect to the given url.

void

saveFollowUpUrl()

Save this request as follow up URL.

void

seoDecode()

Decode a (potentially) rewritten request.

void

setController(ZMController controller)

Set the current controller.

void

setMethod(string method)

Set the request method.

mixed

setParameter(string name, mixed value)

Allow programmatic manipulation of request parameters.

void

setParameterMap(array map)

Set the parameter map.

void

setRequestId(string requestId)

Set the request id.

void

setSession(ZMSession session)

Set the current session instance.

string

url(string requestId, string params, boolean secure)

Create a URL.

boolean

validateSessionToken()

Validate session token.

Methods inherited from org.zenmagick.core\ZMObject
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Constant Detail

mvc\ZMRequest.php at line 39

DEFAULT_REQUEST_ID

public final static str DEFAULT_REQUEST_ID = 'rid'

Default paramter name containing the request id.

Will be used if the 'zenmagick.mvc.request.idName' is not set.


mvc\ZMRequest.php at line 44

SESSION_TOKEN_NAME

public final static str SESSION_TOKEN_NAME = 'stoken'

Name of the session token form field and also the name in the session.


Method Detail

mvc\ZMRequest.php at line 61

__construct

public void __construct(array parameter)

Create new instance.

Parameters:
parameter - Optional request parameter; if null, $_GET and $_POST will be used.

mvc\ZMRequest.php at line 202

absoluteURL

public string absoluteURL(string url, boolean full, boolean secure)

Convert a given relative URL into an absolute one.

Parameters:
url - The (relative) URL to convert.
full - Set to true to create a full URL incl. the protocol, hostname, port, etc.; default is false.
secure - Set to true to force a secure URL; default is false.
Returns:
The absolute URL.

mvc\ZMRequest.php at line 590

closeSession

public void closeSession()

Close session if required.


mvc\ZMRequest.php at line 481

getContext

public string getContext()

Get the URL context for this request.

Returns:
The URL context.

mvc\ZMRequest.php at line 420

getController

public ZMController getController()

Get the controller for this request.

In case the controller is not explicitely set, the method will use the url mapper (ZMUrlManager::instance()->findController()) to determine a controller. This will then be either a configured controller or the default controller.

Returns:
The current controller.

mvc\ZMRequest.php at line 558

getFollowUpUrl

public string getFollowUpUrl(boolean clear)

Check if a follow up url exists that should be loaded (after a login).

Parameters:
clear - Optional flag to keep or clear the follow up url; default is true to clear.
Returns:
The url to go to or null.

mvc\ZMRequest.php at line 287

getHostname

public string getHostname()

Get the hostname for this request.

Returns:
The hostname.

mvc\ZMRequest.php at line 247

getMethod

public string getMethod()

Get the request method.

Returns:
The (upper case) request method.

mvc\ZMRequest.php at line 381

getParameter

public mixed getParameter(string name, mixed default, boolean sanitize)

Generic access method for request parameter.

This method is evaluating both GET and POST parameter.

There is a special case for when a parameter is not found, but _[name] is found. In this case false is returned. This allows to handle checkboxes same as any other form element by adding a hidden field _[name] with the original value.

Parameters:
name - The paramenter name.
default - An optional default parameter (if not provided, null is used).
sanitize - If true, sanitze value; default is true.
Returns:
The parameter value or the default value or null.

mvc\ZMRequest.php at line 315

getParameterMap

public array getParameterMap(boolean sanitize)

Get the complete parameter map.

Parameters:
sanitize - If true, sanitze value; default is true.
Returns:
Map of all request parameters

mvc\ZMRequest.php at line 296

getPort

public string getPort()

Get the port for this request.

Returns:
The port.

mvc\ZMRequest.php at line 578

getProtocol

public string getProtocol()

Get the protocol used.

Returns:
The protocol string.

mvc\ZMRequest.php at line 305

getQueryString

public string getQueryString()

Get the full query string.

Returns:
The full query string for this request.

mvc\ZMRequest.php at line 354

getRequestId

public string getRequestId()

Get the request id.

The request id is the main criteria for selecting the controller and view to process this request.

Returns:
The request id of this request.

mvc\ZMRequest.php at line 342

getRequestIdKey

public string getRequestIdKey()

Get the name of the request parameter that contains the request id.

Returns:
The request id key.

mvc\ZMRequest.php at line 109

getSeoRewriter

public array getSeoRewriter()

Get a list of ZMSeoRewriter instances for SEO urls.

The list is build based on the classes registered via the setting 'zenmagick.mvc.request.seoRewriter'.

Returns:
List of ZMSeoRewriter instances.

mvc\ZMRequest.php at line 265

getSession

public ZMSession getSession()

Get the current session.

Returns:
The session.

mvc\ZMRequest.php at line 505

getTemplatePath

public string getTemplatePath()

Get the template path.

Returns:
The path.

mvc\ZMRequest.php at line 468

getToolbox

public ZMToolbox getToolbox()

Get the toolbox for this request.

Returns:
A toolbox instance.

mvc\ZMRequest.php at line 491

getUri

public string getUri()

Get the uri for this request.

Returns:
The URI.

mvc\ZMRequest.php at line 231

getUser

public mixed getUser()

Get the user (if any) for authentication.

Creation of the user object is delegated to the configured ZMUserFactory instance. The factory may be configured as bean defintion via the setting 'zenmagick.mvc.session.userFactory'.

Returns:
A user/credentials object. Default is null.

mvc\ZMRequest.php at line 514

getWebPath

public string getWebPath()

Get the web path.

Returns:
The path.

mvc\ZMRequest.php at line 97

instance

public static void instance()

Get instance.

A final straw to get the shared request instance if nothing else is available.


mvc\ZMRequest.php at line 442

isSecure

public boolean isSecure()

Checks if the current request is secure or note.

Returns:
true if the current request is secure; eg. SSL, false if not.

mvc\ZMRequest.php at line 453

redirect

public void redirect(string url, int status)

Redirect to the given url.

Parameters:
url - A fully qualified url.
status - Optional status; default is 302 - FOUND.

mvc\ZMRequest.php at line 541

saveFollowUpUrl

public void saveFollowUpUrl()

Save this request as follow up URL.

Typically this happends when a request is received without valid authority. The saved URL will be forwarded to, once permissions is gained (user logged in).


mvc\ZMRequest.php at line 186

seoDecode

public void seoDecode()

Decode a (potentially) rewritten request.


mvc\ZMRequest.php at line 433

setController

public void setController(ZMController controller)

Set the current controller.

Parameters:
controller - The new controller.

mvc\ZMRequest.php at line 256

setMethod

public void setMethod(string method)

Set the request method.

Parameters:
method - The request method.

mvc\ZMRequest.php at line 402

setParameter

public mixed setParameter(string name, mixed value)

Allow programmatic manipulation of request parameters.

Parameters:
name - The paramenter name.
value - The value.
Returns:
The previous value or null.

mvc\ZMRequest.php at line 333

setParameterMap

public void setParameterMap(array map)

Set the parameter map.

Parameters:
map - Map of all request parameters

mvc\ZMRequest.php at line 363

setRequestId

public void setRequestId(string requestId)

Set the request id.

Parameters:
requestId - The new request id.

mvc\ZMRequest.php at line 278

setSession

public void setSession(ZMSession session)

Set the current session instance.

Parameters:
session - The session.

mvc\ZMRequest.php at line 141

url

public string url(string requestId, string params, boolean secure)

Create a URL.

Mother of all URL related methods.

If the requestId parameter is null, the current requestId will be used. The provided parameter(s) will be merged into the current query string.

If the params parameter is null, all parameters of the current request will be added.

This default implementation relies on at least a single (default) SEO rewriter being configured.

Parameters:
requestId - The request id; default is null to use the value of the current request.
params - Query string style parameter; if null add all current parameters; default is an empty string for none.
secure - Flag indicating whether to create a secure or non secure URL; default is false.
Returns:
A full URL.

mvc\ZMRequest.php at line 523

validateSessionToken

public boolean validateSessionToken()

Validate session token.

Returns:
true in case the session token is valid.

ZenMagick 0.9.10