freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\ClassLoading;
/**
* This file should include all necessary classes inside framework
* using lazy include approach if possible.
*
* All classes must be in separate files
* and the physical path to the class files must follow
* the Namespace\Class naming convention starting from component root
*
* @author Jakub PetrĹžĂlka <petrzilka@czweb.net>
*/
class FrameworkLoader extends Loader
{
public static function autoload($class)
{
if (strpos($class, ROOT_NAMESPACE) !== false)
{
/*
* here we cas use include for better efficiency
* because this called only once anyway
*/
$fileName = FRAMEWORK_DIR . DS . str_replace(ROOT_NAMESPACE . DS, "", str_replace('\\', DS, $class)) . '.php';
if (file_exists($fileName))
{
include $fileName;
return true;
}
}
}
public function commit()
{
spl_autoload_register(array(__CLASS__,'autoload'));
}
}