mvcAutoload is an spl_autoload registerable class that provides autoloading functionality for the MVC system. It is set by mvcDistributorBase when it is included.

mvcAutoload works on Controller classes, attempting to locate via the controllerMap the location of the Controller.class.php file within the site structure. By loading the Controller, the View and Model and pre-assigned as the controllerName plus either Model.class.php or View.class.php. Whether they are actually ever used is irrelevant as the autoload only creates a file map and does not actually create the objects. In this way it is similar to the systemAutoload except there are no cache files.

mvcAutoload has another feature: the ability to pre-load classes from the site configuration (config.xml). Any classes specified will be pre-assigned to the autoload array making them available within the sites MVC framework. In this manner it is possible to create custom library files and not have to worry when instantiating the objects.

As of Scorpio; mvcAutoload now builds the entire autoload map for the whole site, including any custom classes.


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

Returns new mvcAutoload instance

public initialise()

Initialises autoloader

public static getInstance()

Returns an instance of mvcAutoload

public static autoload($inClassname)

Convenience method for spl_autoload registration

public static getCacheFolder()

Returns the current mvc autoload cache folder

public loadClass($inClassname)

Attempts to autoload the class named $inClassname

protected _generateClassMap()

Generates an array containing all classes required by the current site

The array is indexed by classname and contains the path to the class relative to the current websites folder.

protected _buildLibraryData([$inAutoloadMap = array()])

Returns an array of mapped library files

protected _buildAutoloadData([$inControllers = array()], [$inAutoloadMap = array()], [$inLevel = 0])

Returns an array of mapped files to locations

protected _includeFile($inClassname)

Includes the file from the autoload cache

public load()

Loads the previously cached autoload map

public save()

Saves the autoload cache to the filesystem

public delete()

Deletes the cache record

public reset()

Resets the mvcAutoload array

public getRequest()

Returns $_Request

public setRequest($inRequest)

Set $_Request to $inRequest

public getSiteConfig()

Returns $_SiteConfig

public setSiteConfig($inSiteConfig)

Set $_SiteConfig to $inSiteConfig

public getClasses()

Returns the entire autoload array

public getClassFile($inClassname)

Returns the file path for $inClassname

public setClassFile($inClassname, $inClasspath)

Sets the class path for $inClassname

private getCacheFile()

Returns the full path to the autoload cache file

public getOptionsSet()

Returns $_OptionsSet

public setOptionsSet($inOptionsSet)

Set $_OptionsSet to $inOptionsSet

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

Returns the option value for $inOption, or $inDefault if not found

public setOption($inOption, $inValue)

Sets a single option $inOption to $inValue

public setOptions($inOptions)

Sets an array of options

public getControllersFolder()

Returns the name of the controllers folder

public getLibrariesFolder()

Returns the name of the libraries folder

Inherited Methods

<  1  >