gnu-social/plugins/Irc/extlib/phergie/Phergie/Autoload.php

82 lines
1.9 KiB
PHP
Raw Normal View History

2010-06-16 09:55:39 +09:00
<?php
/**
2010-07-01 01:33:29 +09:00
* Phergie
2010-06-16 09:55:39 +09:00
*
* PHP version 5
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
* http://phergie.org/license
*
2010-07-01 01:33:29 +09:00
* @category Phergie
2010-06-16 09:55:39 +09:00
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
* @copyright 2008-2010 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
/**
* Autoloader for Phergie classes.
*
2010-07-01 01:33:29 +09:00
* @category Phergie
2010-06-16 09:55:39 +09:00
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
class Phergie_Autoload
{
/**
* Constructor to add the base Phergie path to the include_path.
*
* @return void
*/
public function __construct()
{
2010-07-01 01:33:29 +09:00
$path = realpath(dirname(__FILE__) . '/..');
2010-06-16 09:55:39 +09:00
$includePath = get_include_path();
2010-07-01 01:33:29 +09:00
$includePathList = explode(PATH_SEPARATOR, $includePath);
2010-06-16 09:55:39 +09:00
if (!in_array($path, $includePathList)) {
self::addPath($path);
}
}
/**
* Autoload callback for loading class files.
*
* @param string $class Class to load
*
* @return void
*/
public function load($class)
{
include str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
}
/**
* Registers an instance of this class as an autoloader.
*
* @return void
*/
public static function registerAutoloader()
{
spl_autoload_register(array(new self, 'load'));
}
/**
* Add a path to the include path.
*
* @param string $path Path to add
*
* @return void
*/
public static function addPath($path)
{
set_include_path($path . PATH_SEPARATOR . get_include_path());
}
}