Reads and writes the main site controllerMap.xml file. Internally this is held as a SimpleXML object tree allowing xpath queries to be run against it.

This class is used to map a request to a controller; finding the first most specific match to the request. If no entry is defined for the actual request, the closest match is returned. The match is returned as an mvcControllerMap object.

The _ControllerMap property holds the full map, whereas the mvcControllerMap object contains only the request portion and the path to that request.

As parsing over SimpleXML objects can be awkward when they have been wrapper by utilityOutputWrapper, an additional method is available: getMapAsControllers(). This returns an array containing all the top level controllers and can be safely iterated. The benefit of this approach is that each controller is now a proper mvcControllerMap object and so will wrap all sub-controllers.

// example loading a config file and mapping to a "string" controller
$oMapper = mvcControllerMapper::getInstance('/path/to/controllerMap.xml');
$oMap = $oMapper->getController('/the/request/string');

if ( $oMap->hasSubControllers() ) {
    foreach ( $oMap->getSubControllers as $oSubMap ) {


public __construct()

Creates new mvcControllerMapper

public static getInstance([$inConfigFile = null])

Returns the instance of the mvcControllerMapper

public load($inConfigFile)

Reads the supplied config file and loads the data into the map

public save([$inConfigFile = null])

Writes the config data out to a file

public getLoadedConfigFile()

Returns $_LoadedConfigFile

public setLoadedConfigFile($inLoadedConfigFile)

Returns $_LoadedConfigFile

public getControllerMap()

Returns the SimpleXML object set

public getMapAsControllers()

Returns an array of mvcControllerMap objects

public setControllerMap($inControllerMap)

Sets the SimpleXML controller map

public getController($inControllerName)

Returns controller named $inControllerName

public findController($inRequestPath)

Attempts to find the controller named in $inRequestPath; returns entry from config

public isModified()

Returns $_Modified

public setModified([$inModified = true])

Returns $_Modified

<  1  >