ZenMagick 0.9.8


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

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
Version:
$Id: ZMUrlManager.php 2757 2009-12-18 01:05:38Z dermanomann $

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMUrlManager()

Create new instance.

Method Summary
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.

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

Constructor Detail

\mvc\ZMUrlManager.php at line 47

ZMUrlManager

public ZMUrlManager()

Create new instance.


Method Detail

\mvc\ZMUrlManager.php at line 70

clear

public void clear()

Clear all mappings.


\mvc\ZMUrlManager.php at line 170

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 125

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 201

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 62

instance

public static void instance()

Get instance.


\mvc\ZMUrlManager.php at line 81

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 93

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.

ZenMagick 0.9.8