/**
* Class to load unloaded classfiles.
*
* @abstract
* @author Rainer Schulz <admin@raischblog.de>
* @link http://raischblog.de
* @copyright 2011 - Rainer Schulz
* @license CC BY-NC-SA 3.0 <http://creativecommons.org/licenses/by-nc-sa/3.0/>
* @version 2.2 02/12/2011 14:13
*/
abstract class AutoLoad
{
private static $arrPath = null;
private static $arrExt = null;
public static function init( $strClassPath,
$strInterfacePath,
$strLibraryPath,
$strModelPath,
$strViewPath,
$strControllerPath,
$strRepositoryPath )
{
self::$arrPath = array (
'class' => $strClassPath,
'interface' => $strInterfacePath,
'library' => $strLibraryPath,
'model' => $strModelPath,
'view' => $strViewPath,
'controller' => $strControllerPath,
'repository' => $strRepositoryPath
);
self::$arrExt = array(
'class' => '.class.php',
'interface' => '.interface.php',
'library' => '.library.php'
);
spl_autoload_register( 'AutoLoad::loadClass' );
spl_autoload_register( 'AutoLoad::loadLibrary' );
spl_autoload_register( 'AutoLoad::loadController' );
spl_autoload_register( 'AutoLoad::loadModel' );
spl_autoload_register( 'AutoLoad::loadRepository' );
spl_autoload_register( 'AutoLoad::loadView' );
spl_autoload_register( 'AutoLoad::loadInterface' );
}
public static function loadClass( $strClass )
{
return self::registerClass(
self::$arrPath['class'].$strClass.self::$arrExt['class']
);
}
public static function loadInterface( $strClass )
{
return self::registerClass(
self::$arrPath['interface'].$strClass.self::$arrExt['interface']
);
}
public static function loadLibrary( $strClass )
{
return self::registerClass(
self::$arrPath['library'].$strClass.self::$arrExt['library']
);
}
public static function loadModel( $strClass )
{
return self::registerClass(
self::$arrPath['model'].$strClass.self::$arrExt['class']
);
}
public static function loadView( $strClass )
{
return self::registerClass(
self::$arrPath['view'].$strClass.self::$arrExt['class']
);
}
public static function loadController( $strClass )
{
return self::registerClass(
self::$arrPath['controller'].$strClass.self::$arrExt['class']
);
}
public static function loadRepository( $strClass )
{
return self::registerClass(
self::$arrPath['repository'].$strClass.self::$arrExt['class']
);
}
private static function registerClass( $strFile )
{
if ( is_file( $strFile ) )
{
require $strFile;
return true;
}
return false;
}
}