ZenMagick 0.9.6


org.zenmagick.rp.ZMUrlMapper

Class ZMUrlMapper

ZMObject
|
+--ZMUrlMapper

public class ZMUrlMapper
extends ZMObject

Handle URL mappings.

The URL mappings connect the requested page (value of ZM_PAGE_KEY) with a view (template) and optionally a controller to handle the request.

The default behaviour for controller is to build the controller class using the ZM_PAGE_KEY value.

Furthermore, depending on the processing of a request in a controller, different views may be returned. This is archived by mapping the actual template name not to a request (ZM_PAGE_KEY value) or controller class, but to a logical key that is used by the controller to lookup the actual view template.

Finally, there are optional settings for form validation that are not used (yet).

Author:
DerManoMann
Version:
$Id: ZMUrlMapper.php 2170 2009-04-21 04:56:09Z dermanomann $

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMUrlMapper()

Create new instance.

Method Summary
ZMController

findController(string page)

Find the controller (class) mapped to the given page.

array

findMapping(string page, string viewId, mixed parameter)

Find a URL mapping for the given controller (and viewId).

string

getViewDefinition(string page, string viewId, mixed parameter)

Get the view definition string for the given controller (and viewId).

static void

instance()

Get instance.

void

setMappingInfo(string page, array viewInfo)

Set a mapping for the given page $page.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Constructor Detail

ZMUrlMapper

public ZMUrlMapper()

Create new instance. /


Method Detail

findController

public ZMController findController(string page)

Find the controller (class) mapped to the given page.

Unless explicitely configured, the controller class name will be build from the given page name.

If no page specific controller is found, an instance of ZMSettings::get('defaultControllerClass') will be returned.

Parameters:
page - The page name.
Returns:
A controller instance to handle the request.

findMapping

public array findMapping(string page, string viewId, mixed parameter)

Find a URL mapping for the given controller (and viewId).

Parameters:
page - The page name.
viewId - The viewId; defaults to null to use the controller.
parameter - Optional map of name/value pairs (or URL query format string) * to further configure the view; default is null.
Returns:
A mapping or null.

getViewDefinition

public string getViewDefinition(string page, string viewId, mixed parameter)

Get the view definition string for the given controller (and viewId).

Parameters:
page - The page name.
viewId - The viewId; defaults to null to use the controller.
parameter - Optional map of name/value pairs (or URL query format string) * to further configure the view; default is null.
Returns:
A best match view definition.

instance

public static void instance()

Get instance. /


setMappingInfo

public void setMappingInfo(string page, array viewInfo)

Set a mapping for the given page $page.

Supported $viewInfo keys (viewDefinition, controllerDefinition and formClass allow either a bean definitions or a plain class name):

viewId
The view id. This is the key the controller will use to lookup a view template name; default is the value of $page.
view
The corresponding view template; this is the name of the view filename without the file extension;
default is the value of $page.
viewDefinition
The actual ZMView implementation class to use; default is PageView.
controllerDefinition
The class name for the controller to handle this page; default is null to use $page to build a classname (see ZMLoader::makeClassname(string) for details).
formId
Optional name of the form for automatic request validation; default is null for none.
formDefinition
Optional form model definition; default is null for none.

In the case of $page being null, at least viewId is required.

Parameters:
page - The page name; null may be used to lookup shared mappings.
viewInfo - View details; default is an empty array - array().

ZenMagick 0.9.6