ZMObject
└─ZMController
└─ZMAjaxController
public class ZMAjaxController
extends ZMController
| Method Summary | |
|---|---|
| void | __construct(string requestId) Create new instance. |
| array | flattenObject(mixed obj, mixed properties, function formatter, array methods) Flattens any given object. |
| ZMView | Process a HTTP request. |
| ZMView | processGet(ZMRequest request) Process a HTTP GET request. |
| void | setJSONHeader(string json) Set JSON response header ('X-JSON'). |
| string | toJSON(mixed obj) Serialize object to JSON. |
| Methods inherited from org.zenmagick.mvc.controller\ZMController | |
|---|---|
| __construct, findView, getFormData, getId, getView, getViewData, isAjax, isFormSubmit, preProcess, process, processGet, processPost, setContentType, setId, setView, validate, validateFormData, validateSession | |
| Methods inherited from org.zenmagick.core\ZMObject | |
|---|---|
| __construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton | |
public void __construct(string requestId)
Create new instance.
null to use the request id.public array flattenObject(mixed obj, mixed properties, function formatter, array methods)
Flattens any given object.
Criteria for the included data is the ZenMagick naming convention that access methods start with
either get, is or has.
If the given object is an array, all elements will be converted, too. Generally speaking, this method works recursively. Arrays are preserved, array values, in turn, will be flattened.
The methods array may contain nested arrays to allow recursiv method mapping. The Ajax product controller is a good example for this.
formatter($obj, $name, $value).public ZMView process(ZMRequest request)
Process a HTTP request.
This implementation will delegate request handling based on the method parameter in
the request. If no method is found, the default parent process() implementation
will be called.
Also, if the passed method is not found, the controller will try to resolve the method by appending the
configured ajaxFormat string. So, if, for example, the method is getCountries and ajaxFormat is
JSON, the controller will first look for getCountries and then for getCountriesJSON.
ZMView instance or null.public ZMView processGet(ZMRequest request)
Process a HTTP GET request.
Just return null.
ZMView that handles presentation or null if the controller generates the contents itself.public void setJSONHeader(string json)
Set JSON response header ('X-JSON').
public string toJSON(mixed obj)
Serialize object to JSON.
Request controller for ajax requests.
Uses native PHP function
json_encode.