mirror of
https://github.com/tursom/typecho-plugin-Access.git
synced 2026-08-19 08:13:27 +08:00
添加自动加载类 Access_Autoloader
This commit is contained in:
28
Access_Autoloader.php
Normal file
28
Access_Autoloader.php
Normal 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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user