freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\ClassLoading;
/**
*
* Loads site application classes
*
* @author Jakub PetrĹžĂlka <petrzilka@czweb.net>
*/
class ApplicationLoader extends Loader
{
public function commit()
{
spl_autoload_register(function ($class)
{
if ((strpos($class, APP_NAMESPACE) !== false)&&((strpos($class,"__CG__") === false)))
{
/*
* here we cas use include for better efficiency
* because this called only once anyway
*/
// echo APP_DIR."\n";
$path = APP_DIR . DS
. str_replace(APP_NAMESPACE . DS, "", str_replace('\\', DS, $class))
. '.php';
//echo "path: ".$path."\n\n";
include $path;
}
});
/* INIT APPLICATION */
$bootstrapperClass = APP_NAMESPACE . "\\" . APP_NAME . "Boot";
if (!class_exists($bootstrapperClass))
die("Invalid application bootfile (missing ". $bootstrapperClass ." class) ");
//the class must be descendant of BootStrapper
$bootstrapper = new $bootstrapperClass();
if (!is_a($bootstrapper, "Phem\ClassLoading\Bootstrapping\Bootstrapper"))
die("Application bootstrapper must be inherited from Bootstrapper class");
$bootstrapper->init();
}
}