Abstract mvcDistributorBase class. Provides base functionality for the MVC system. This is the main Front Controller class that will dispatch a request to an appropriate controller within the site hierarchy.

The main functions of this class are to prepare the request, create or continue a session, determine the request type (or context if you prefer) and to then dispatch the request to the most appropriate controller as defined in the controllerMap XML config file.

A concrete implementation is required of the dispatch() method.

The basic process flow of mvcDistributorBase is as follows:

  1. Request passed to new distributor instance
  2. mvcAutoload registered to spl_autoload for handling controllers
  3. Resolve the site and hence the site config
  4. Execute plugins mvcDistributorPlugin::executeOnDispatcherInitialise() event
  5. Execute main dispatch method
  6. Execute plugins mvcDistributorPlugin::executePreDispatch() event
  7. Resolve the path to the most appropriate controller
  8. Load the controller object
  9. Validate request action against controller
  10. Authorise request action against controller
  11. Launch controller
  12. Execute plugins mvcDistributorPlugin::executePostDispatch() event
  13. Shutdown
  14. Execute plugins mvcDistributorPlugin::executeOnShutdown() event

Scorpio is designed to work with multiple sites with a shared code-base. Each site can inherit from a base set of functionality with specific components being overridden. Which site to use is determined by mvcDistributorBase::resolveSitePath(). This method will hunt through the /websites folder attempting to match the request domain to a folder entry, first by specific domain e.g. and then by component separated by each . e.g. In this way, all requests for pages can be directed to a domain, and then content switched on a sub-domain. For example: all requests to would be serviced using the site, but wap. would result in WAP content being returned to the user.

This basic functionality can always be overridden by appending /as.TYPE to the URI request. These requests will then be filtered out and the alternative type returned. Supported out-put types include: HTML (XHTML for web), XHTML (for mobile), WML (for mobile), RSS, XML, ATOM, JSON and JavaScript. WAP requests are auto-negotiated for MXHTML or WML by accept-type look-up and user-agent negotiation. All XHTML Mobile requests are served using application/xhtml+xml as this is the mandated content-type by the network 3.

Once resolved, the site config.xml file is loaded into the mvcSiteConfig object. This contains theme and custom library information. This is processed before the request as the specific session and view classes must be pre-loaded before dispatch can continue.

For request routing please see mvcControllerMapper.

Some additional parameters of the distributor can be configured by defining constants before the base class is included. These constants control where the site folder is, what the controllers folder is called, the name of the custom libraries folder, views and the default action to be fired when no action can be located in the request e.g. launching /home or /index when the request is simply /.

The loading of the various controllers is handled via a custom spl_autoload class mvcAutoload. This will pre-load and fetch controllers, models and views for the request based on the site controllerMap.xml file.

The distributor has several options that can be specified during instantiation:

mvcDistributorBase::OPTION_DISTRIBUTOR_WEBSITES_FOLDER The full path to the main websites folder, defaults to /websites.

mvcDistributorBase::OPTION_DISTRIBUTOR_WEBSITE_CONTROLLERS_FOLDER The name of the controllers folder, defaults to "controllers". This is where the controllers can be located.

mvcDistributorBase::OPTION_DISTRIBUTOR_WEBSITE_DEFAULT_CONTROLLER The name of the default controller, defaults to "home". If no request is specified then this controller will be used.

mvcDistributorBase::OPTION_DISTRIBUTOR_WEBSITE_LIBRARIES_FOLDER The name of the libraries folder, defaults to "libraries". The libraries folder contains the mvcController, mvcSession and mvcView classes along with other custom classes for the site.

mvcDistributorBase::OPTION_DISTRIBUTOR_WEBSITE_VIEWS_FOLDER The name of the views folder, defaults to "views". The views are the templates to be used for the site.

mvcDistributorBase::OPTION_DISTRIBUTOR_ERROR_CONTROLLER Name of class implementing mvcErrorInterface, defaults to mvcErrorController.


public __construct($inRequest, [$inOptions = array()])

Returns new mvcDistributorBase instance

public reset()

Resets the object to defaults

public initialise()

Initialises the distributor prior to request dispatch

public abstract dispatch()

Routes the request launching any controller that is needed

public resolveSitePath()

Finds the site path in the websites folder based on the server name

public resolveController()

Parses the request URI for the controller, returning controllerMap object

public loadController()

Loads the controller from the request controllerMap

public getRequest()

Returns the mvcRequest object

public setRequest($inMvcRequest)

Set $_MvcRequest to $inMvcRequest

public getResponse()

Returns the mvcResponse object, creating a default if not set

public setResponse($inMvcResponse)

Set $_MvcResponse to $inMvcResponse

public getSiteConfig()

Returns the site config object by lazy load

public setSiteConfig($inSiteConfig)

Set the siteConfig instance

public getPluginSet()

Returns the plugin set, lazy-loading it if the object does not exist

public setPluginSet($inSet)

Allows the plugins to be set manually

protected buildPath([$inPath = null])

Returns a properly formed path/to/the/thing with / set to the system dir separator

Path can be a string, array or mvcControllerMap object. If $inPath is null, the current request in the controller map is used.

public includeLibraryFile($inLibraryFile, [$inPath = null])

Includes a file from the libraries folder of the site

public includeControllerFile($inControllerFile, [$inPath = null])

Includes a file from the controllers folder of the site

public includeControllerUnit($inControllerName, [$inPath = null])

Includes an entire unit based on $inControllerName

e.g. $inControllerName = 'login', $inPath = '/user/login'

Loads controller filename: loginController.class.php from /user/login Loads model filename: loginModel.class.php from /user/login Loads view filename: loginView.class.php from /user/login

public getControllerFile($inFileName, [$inPath = null])

Returns the path to the controller file located in the sites website.controllers.folder (default controllers)

public getTemplateFile($inFileName, [$inPath = null])

Returns the path to the specified template file, uses current controller path if none specified template must be located in views/controller/path. Template must be located within distributor.views.folder (default views)

public getLibraryFile($inFileName, [$inPath = null])

Returns the full path to the specified file to be included in relation to the current site and contained within the website.libraries.folder folder of that site (default libraries)

public getPluginFile($inFileName, [$inPath = null])

Returns the path to the specified plugin file, this method allows the plugin library files to be located outside of the site hierarchy. This will check the parent sites for a value, returns false if file does not exist or param not found.

public getOptions()

Returns the instance of baseOptionsSet

public getOption([$inOption = null], [$inDefault = null])

Returns options or a specific option, null if not found

public getDistributorWebsitesFolder()

Returns the websites folder

public getDistributorDefaultController()

Returns the default controller name

public getDistributorControllersFolder()

Returns the name of the controllers folder

public getDistributorLibrariesFolder()

Returns the name of the libraries folder

public getDistributorViewsFolder()

Returns the name of the views folder

public getDistributorErrorController()

Returns the error controller that will handle errors

public setOptions($inOptions)

Set options to $inOptions

$inOptions can be either an associative array or an instance of baseOptionsSet

<  1  >