|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("JsonAutoload.php");
|
|
|
|
|
|
|
|
class Autoload
|
|
|
|
{
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
spl_autoload_extensions(".php");
|
|
|
|
spl_autoload_register(array($this, 'SIP_autoload'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* selecionar qual biblioteca chamar */
|
|
|
|
private function SIP_Autoload($classname)
|
|
|
|
{
|
|
|
|
$classname = $this->LibAutoload($classname, new JsonAutoload());
|
|
|
|
$path_filename = preg_replace("/\\\\/", "/", "$classname");
|
|
|
|
$file_to_load = "$path_library$path_filename.php";
|
|
|
|
|
|
|
|
$this->include_file($file_to_load);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function LibAutoload($classname, $autoload_json)
|
|
|
|
{
|
|
|
|
$classname = $autoload_json->get_NamespaceToPathname($classname);
|
|
|
|
return $classname;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function include_file($file)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
require_once($file);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
echo "$file\n", $e->getMessage(), "\n";
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Autoload();
|