添加自动加载类 Access_Autoloader

This commit is contained in:
kokororin
2017-07-15 13:47:33 +08:00
parent ddcfe30466
commit 0aa76d751e
4 changed files with 33 additions and 6 deletions

28
Access_Autoloader.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
if (!defined('__ACCESS_PLUGIN_ROOT__')) {
throw new Exception('Boostrap file not found');
}
class Access_Autoloader
{
public static function autoloader($class)
{
if (strpos($class, 'Access') !== 0) {
return;
}
$file = __ACCESS_PLUGIN_ROOT__ . '/' . $class . '.php';
if (file_exists($file)) {
require_once $file;
}
}
public static function register()
{
if (function_exists('spl_autoload_register')) {
spl_autoload_register(array('Access_Autoloader', 'autoloader'));
} else {
throw new Typecho_Plugin_Exception(_t('php版本过低最低要求>=5.3.0'));
}
}
}