ZenMagick 0.9.10


org.zenmagick.mvc\ZMUrlManager
mvc\ZMUrlManager.php at line 38

Class ZMUrlManager

ZMObject
└─ZMUrlManager

public class ZMUrlManager
extends ZMObject

Central storage of url mappings.

URL mappings map things like the controller, view and template used to a requestId.

To simplify, there are a lot of conventions and defaults to minimize the need for using mappings.

Mappings may be set explicitely via the setMapping() method. However, the preferred way is to load mappings from a configuration (YAML) file.

Author:
DerManoMann

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

__construct()

Create new instance.

void

clear()

Clear all mappings.

ZMController

findController(string requestId)

Find and instantiate a controller object for the given request id.

array

findMapping(string requestId, string viewId, mixed parameter)

Find a mapping for the given requestId (and viewId).

ZMView

findView(string requestId, string viewId, mixed parameter)

Find and instantiate a view object for the given request id (and view id).

static void

instance()

Get instance.

void

load(string yaml, boolean override)

Load mappings from a YAML style string.

void

setMapping(string requestId, mixed mapping, boolean override)

Set mapping details for a given request id.

void

setMappings(mixed mappings, boolean override)

Set multiple mappings.

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

Method Detail

mvc\ZMUrlManager.php at line 46

__construct

public void __construct()

Create new instance.


mvc\ZMUrlManager.php at line 69

clear

public void clear()

Clear all mappings.


mvc\ZMUrlManager.php at line 190

findController

public ZMController findController(string requestId)

Find and instantiate a controller object for the given request id.

Determining the controller class is a three stage process:

  1. Check if a controller definition is mapped to the given request id
  2. Derive a controller class name from the request id and check if the resulting class exists
  3. Use the configured default controller definition, as set via 'zenmagick.mvc.controller.default'

Parameters:
requestId - The request id.
Returns:
A controller instance to handle the request.

mvc\ZMUrlManager.php at line 144

findMapping

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

Find a mapping for the given requestId (and viewId).

This method will use a number of fallback/default conventions for missing mappings:

If no mapping is found for the given requestId, the global mappings will be queried. Should that fail as well, null will be returned.

If mappings are found, the most specific values are returned. Mapping keys that do not exit will be populated with a value of null.

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

mvc\ZMUrlManager.php at line 221

findView

public ZMView findView(string requestId, string viewId, mixed parameter)

Find and instantiate a view object for the given request id (and view id).

If no mapping is found, some sensible defaults will be used.

The default view (definition) will is taken from the setting 'zenmagick.mvc.view.default'.

Parameters:
requestId - The request id.
viewId - Optional view id; defaults to null to use defaults.
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.

mvc\ZMUrlManager.php at line 61

instance

public static void instance()

Get instance.


mvc\ZMUrlManager.php at line 80

load

public void load(string yaml, boolean override)

Load mappings from a YAML style string.

Parameters:
yaml - The yaml style mappings.
override - Optional flag to control whether to override existing mappings or to merge; default is true to override.

mvc\ZMUrlManager.php at line 92

setMapping

public void setMapping(string requestId, mixed mapping, boolean override)

Set mapping details for a given request id.

Parameters:
requestId - The request id to configure.
mapping - The mapping, either as YAML string fragment or nested array.
override - Optional flag to control whether to override existing mappings or to merge; default is true to override.

mvc\ZMUrlManager.php at line 115

setMappings

public void setMappings(mixed mappings, boolean override)

Set multiple mappings.

Parameters:
mappings - The mappings, either as YAML string fragment or nested array.
override - Optional flag to control whether to override existing mappings or to merge; default is true to override.

ZenMagick 0.9.10