コード例 #1
0
ファイル: ark.php プロジェクト: ddliu/tinyark
        foreach (self::$dirs as $dir => $hasChild) {
            if ($hasChild) {
                $file = $dir . '/' . $name_path . '.php';
            } else {
                $file = $dir . '/' . $name . '.php';
            }
            if (file_exists($file)) {
                require $file;
                return true;
            }
        }
        return false;
    }
    public static function registerPrefix($prefix, $path)
    {
        self::$prefixes[$prefix] = $path;
    }
    public static function loadPrefix($name)
    {
        foreach (self::$prefixes as $prefix => $path) {
            $prefix_length = strlen($prefix);
            if (substr($name, 0, $prefix_length + 1) === $prefix . '_') {
                $file = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
                require $file;
                return true;
            }
        }
    }
}
Ark::autoloadFramework();