forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1005 B
49 lines
1005 B
1 year ago
|
<?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();
|
||
|
|
||
|
|