contenido\classes\class.autoload.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: CONTENIDO Content Management System

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

Package: Default

Constants

>VConstant  ERROR_FILE_NOT_FOUND = 'file_not_found'
>VConstant  ERROR_CLASS_EXISTS = 'class_exists'

Properties

>VPropertyprivatestring $_conRootPath = null
static
CONTENIDO root path.

Path to the folder which contains the CONTENIDO installation.

Default valuenullDetails
Type
string
>VPropertyprivatearray $_errors = array()
static
Array to store invalid classnames and the paths to the class files.

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

Default valuearray()Details
Type
array
>VPropertyprivatearray $_includeFiles = null
static
Array of interface/class names with related files to include
Default valuenullDetails
Type
array
>VPropertyprivatebool $_initialized = null
static
Flag containing initialized status
Default valuenullDetails
Type
bool
>VPropertyprivatearray $_loadedClasses = array()
static
Array to store loaded classnames and the paths to the class files.

$_loadedClasses['classname'] = '/path/to/the/class.php';

Default valuearray()Details
Type
array

Methods

methodprivate_getContenidoClassFile(string $className) : \(string | \null)
static

Returns the path to a CONTENIDO class file by processing the given classname

Parameters
NameTypeDescription
$classNamestring
Returns
TypeDescription
\(string | \null)Path and filename or null
methodprivate_loadFile(string $filePathName, bool $beQuiet = false) : void
static

Loads the desired file by invoking require_once method

Parameters
NameTypeDescription
$filePathNamestring
$beQuietbool

Flag to prevent thrown warnings/errors by using the error control operator @

methodprivate_normalizeConfig(array $config) : array
static

Normalizes 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'.

Parameters
NameTypeDescription
$configarray
Returns
TypeDescription
array
methodprivate_validateClassAndFile(string $className, string $filePathName) : \(string | \null)
static

Validates the given class and the file

Parameters
NameTypeDescription
$classNamestring
$filePathNamestring
Returns
TypeDescription
\(string | \null)The file if validation was successfull, otherwhise null
methodpublicaddClassmapConfig(array $config) : void
static

Adding 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.

Parameters
NameTypeDescription
$configarray

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',
);
methodpublicaddClassmapConfigFile(string $configFile) : void
static

Adding 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.

Parameters
NameTypeDescription
$configFilestring

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',
);
methodpublicautoload(string $className) : void
static

The main __autoload() implementation.

Tries to include the file of passed classname.

Parameters
NameTypeDescription
$classNamestring

The classname

Throws
ExceptionDescription
\cBadMethodCallExceptionIf autoloader wasn't initialized before
methodpublicgetErrors() : array
static

Returns the errorlist containing invalid classes (@see cAutoload::$_errors)

Returns
TypeDescription
array
methodpublicgetLoadedClasses() : array
static

Returns the loaded classes (@see cAutoload::$_loadedClasses)

Returns
TypeDescription
array
methodpublicinitialize(array $cfg) : void
static

Initialization 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.

Parameters
NameTypeDescription
$cfgarray

The CONTENIDO cfg array

methodpublicisAutoloadable(string $file) : bool
static

Checks, if passed filename is a file, which will be included by the autoloader.

Parameters
NameTypeDescription
$filestring

Filename or Filename with a part of the path, e. g. - class.foobar.php - classes/class.foobar.php - contenido/classes/class.foobar.php

Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.0.0a12.