contenido\classes\class.autoload.php
Description: Implements autoload feature for a CONTENIDO project.
Autoloading for CONTENIDO is provided via a generated class map configuration file, which is available inside contenido/includes/ folder. - contenido/includes/config.autoloader.php
Autoloading is extendable by adding a additional class map file inside the same folder, which could contain further class map settings or could overwrite settings of main class map file. - contenido/includes/config.autoloader.local.php
You can also add additional class map configuration by using function following functions: - cAutoload::addClassmapConfig(array $config) - cAutoload::addClassmapConfigFile($configFile)
Read also docs/techref/backend/backend.autoloader.html to get involved in CONTENIDO autoloader mechanism.
Requirements:
- Author
- Murat Purc
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- CONTENIDO Autoloader
- Since
- file available since CONTENIDO release 4.8.17 {@internal created 2010-12-27 $Id: class.autoload.php 3461 2012-10-16 19:50:54Z xmurrix $: }}
- Version
- 0.1.0
\cAutoload
Constants
Properties

string $_conRootPath = nullPath to the folder which contains the CONTENIDO installation.
nullDetails- Type
- string

array $_errors = array()$_errors[pos] = array('class' => classname, 'file' => file, 'error' => errorType);
array()Details- Type
- array

array $_includeFiles = nullnullDetails- Type
- array
Methods

_getContenidoClassFile(string $className) : \(string | \null)Returns the path to a CONTENIDO class file by processing the given classname
| Name | Type | Description |
|---|---|---|
| $className | string |
| Type | Description |
|---|---|
| \(string | \null) | Path and filename or null |

_loadFile(string $filePathName, bool $beQuiet = false) : voidLoads the desired file by invoking require_once method
| Name | Type | Description |
|---|---|---|
| $filePathName | string | |
| $beQuiet | bool | Flag to prevent thrown warnings/errors by using the error control operator @ |

_normalizeConfig(array $config) : arrayNormalizes the passed configuration array by returning a new copy of it which contains the keys in lowercase.
This prevents errors by trying to load class 'foobar' if the real class name is 'FooBar'.
| Name | Type | Description |
|---|---|---|
| $config | array |
| Type | Description |
|---|---|
| array |

_validateClassAndFile(string $className, string $filePathName) : \(string | \null)Validates the given class and the file
| Name | Type | Description |
|---|---|---|
| $className | string | |
| $filePathName | string |
| Type | Description |
|---|---|
| \(string | \null) | The file if validation was successfull, otherwhise null |

addClassmapConfig(array $config) : voidAdding additional autoloader class map configuration.
NOTE: Since this autoloader is implemented for CONTENIDO, it doesn't support to load classfiles being located outside of the CONTENIDO installation folder.
| Name | Type | Description |
|---|---|---|
| $config | array | Assoziative class map array as follows:
// Structure is: "Classname" => "Path to classfile from CONTENIDO installation folder"
$config = array(
'myPluginsClass' => 'contenido/plugins/myplugin/classes/class.myPluginClass.php',
'myPluginsOtherClass' => 'contenido/plugins/myplugin/classes/class.myPluginsOtherClass.php',
);
|

addClassmapConfigFile(string $configFile) : voidAdding additional autoloader class map configuration file.
NOTE: Since this autoloader is implemented for CONTENIDO, it doesn't support to load classfiles being located outside of the CONTENIDO installation folder.
| Name | Type | Description |
|---|---|---|
| $configFile | string | Full path to class map configuration file. The provided file must return a class map configuration array as follows:
// Structure is: "Classname" => "Path to classfile from CONTENIDO installation folder"
return array(
'myPluginsClass' => 'contenido/plugins/myplugin/classes/class.myPluginClass.php',
'myPluginsOtherClass' => 'contenido/plugins/myplugin/classes/class.myPluginsOtherClass.php',
'myCmsClass' => 'cms/includes/class.myCmsClass.php',
);
|

autoload(string $className) : voidThe main __autoload() implementation.
Tries to include the file of passed classname.
| Name | Type | Description |
|---|---|---|
| $className | string | The classname |
| Exception | Description |
|---|---|
| \cBadMethodCallException | If autoloader wasn't initialized before |

getErrors() : arrayReturns the errorlist containing invalid classes (@see cAutoload::$_errors)
| Type | Description |
|---|---|
| array |

getLoadedClasses() : arrayReturns the loaded classes (@see cAutoload::$_loadedClasses)
| Type | Description |
|---|---|
| array |

initialize(array $cfg) : voidInitialization of CONTENIDO autoloader, is to call at least once.
Registers itself as a __autoload implementation, includes the class map file, and if exists, the user defined class map file, containing the includes.
| Name | Type | Description |
|---|---|---|
| $cfg | array | The CONTENIDO cfg array |

isAutoloadable(string $file) : boolChecks, if passed filename is a file, which will be included by the autoloader.
| Name | Type | Description |
|---|---|---|
| $file | string | Filename or Filename with a part of the path, e. g. - class.foobar.php - classes/class.foobar.php - contenido/classes/class.foobar.php |
| Type | Description |
|---|---|
| bool |