ZenMagick 0.9.10


org.zenmagick.mvc.controller\ZMController
mvc\controller\ZMController.php at line 30

Class ZMController

ZMObject
└─ZMController

public class ZMController
extends ZMObject

Request controller base class.

Author:
DerManoMann

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

__construct(string requestId)

Create new instance.

ZMView

findView(string id, array data, array parameter)

Lookup the appropriate view for the given name.

ZMObject

getFormData(ZMRequest request)

Get the form data object (if any) for this request.

string

getId()

Get the controller id.

ZMView

getView()

Get the current view.

array

getViewData(ZMRequest request)

Get general page data.

boolean

isAjax(ZMRequest request)

Check if the current request is an Ajax request.

boolean

isFormSubmit(ZMRequest request)

Check if this request is a form submit.

void

preProcess(ZMRequest request)

Convenience method for request processing shared by request methods.

ZMView

process(ZMRequest request)

Process a HTTP request.

ZMView

processGet(ZMRequest request)

Process a HTTP GET request.

ZMView

processPost(ZMRequest request)

Process a HTTP POST request.

void

setContentType(string type, string charset)

Set the response content type.

void

setId(string id)

Set the controller id.

void

setView(ZMView view)

Set the current view.

boolean

validate(ZMRequest request, string formId, mixed formData)

Validate the current request using the given rule id.

protected ZMView

validateFormData(ZMRequest request, mixed formData)

Validate the given form bean.

protected ZMView

validateSession(ZMRequest request)

Validate session token.

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

Method Detail

mvc\controller\ZMController.php at line 42

__construct

public void __construct(string requestId)

Create new instance.

Parameters:
requestId - Optional requestId; default is null to use the request id.

mvc\controller\ZMController.php at line 259

findView

public ZMView findView(string id, array data, array parameter)

Lookup the appropriate view for the given name.

Parameters:
id - The controller id or null to return to the current page.
data - Optional model data; default is an empty array.
parameter - Optional map of name/value pairs to further configure the view; default is null.
Returns:
The actual view to be used to render the response.

mvc\controller\ZMController.php at line 282

getFormData

public ZMObject getFormData(ZMRequest request)

Get the form data object (if any) for this request.

Parameters:
request - The request to process.
Returns:
An object instance or null

mvc\controller\ZMController.php at line 386

getId

public string getId()

Get the controller id.

Returns:
The id (page name).

mvc\controller\ZMController.php at line 361

getView

public ZMView getView()

Get the current view.

Returns:
The view or null.

mvc\controller\ZMController.php at line 176

getViewData

public array getViewData(ZMRequest request)

Get general page data.

Good to override if a custom controller needs to provide some data for both GET and POST requests.

Parameters:
request - The current request.
Returns:
Some data map.

mvc\controller\ZMController.php at line 201

isAjax

public boolean isAjax(ZMRequest request)

Check if the current request is an Ajax request.

This default implementation will check for a 'X-Requested-With' header. Subclasses are free to extend and override this method for custom Ajax detecting.

Parameters:
request - The request to process.
Returns:
true if this request is considered an Ajax request.

mvc\controller\ZMController.php at line 215

isFormSubmit

public boolean isFormSubmit(ZMRequest request)

Check if this request is a form submit.

This default implementation will return true for all POST requests.

Parameters:
request - The request to process.
Returns:
true if this is a form submit request.

mvc\controller\ZMController.php at line 188

preProcess

public void preProcess(ZMRequest request)

Convenience method for request processing shared by request methods.

Despite the name this is called as part of the controllers process($request) method. That ensures that all processing is within the boundaries of a single transaction (if enabled).

Parameters:
request - The request to process.

mvc\controller\ZMController.php at line 66

process

public ZMView process(ZMRequest request)

Process a HTTP request.

Supported request methods are GET and POST.

This method should not be overridded!.

Parameters:
request - The request to process.
Returns:
A ZMView instance or null.

mvc\controller\ZMController.php at line 226

processGet

public ZMView processGet(ZMRequest request)

Process a HTTP GET request.

Parameters:
request - The request to process.
Returns:
A ZMView that handles presentation or null if the controller generates the contents itself.

mvc\controller\ZMController.php at line 238

processPost

public ZMView processPost(ZMRequest request)

Process a HTTP POST request.

Parameters:
request - The request to process.
Returns:
A ZMView that handles presentation or null if the controller generates the contents itself.

mvc\controller\ZMController.php at line 247

setContentType

public void setContentType(string type, string charset)

Set the response content type.

Parameters:
type - The content type.
charset - Optional charset; default is utf-8; null will omit the charset part.

mvc\controller\ZMController.php at line 379

setId

public void setId(string id)

Set the controller id.

Parameters:
id - The id (page name).

mvc\controller\ZMController.php at line 370

setView

public void setView(ZMView view)

Set the current view.

Parameters:
view - The view or null.

mvc\controller\ZMController.php at line 335

validate

public boolean validate(ZMRequest request, string formId, mixed formData)

Validate the current request using the given rule id.

Parameters:
request - The request to process.
formId - The ZMRuleSet id.
formData - A map, (bean) object instance or null for all current request parameter.
Returns:
true if the validation was successful, false if not.

mvc\controller\ZMController.php at line 314

validateFormData

protected ZMView validateFormData(ZMRequest request, mixed formData)

Validate the given form bean.

Parameters:
request - The request to process.
formData - An object.
Returns:
Either the error view (in case of validation errors), or null for success.

mvc\controller\ZMController.php at line 303

validateSession

protected ZMView validateSession(ZMRequest request)

Validate session token.

Parameters:
request - The request to process.
Returns:
Either the error view (in case of validation errors), or null for success.

ZenMagick 0.9.10