blob: 0004f44e2211c4a1f1728facbc1d1aeef811ea56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
/**
* Phergie
*
* 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
*
* @category Phergie
* @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.
*
* @category Phergie
* @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()
{
$path = realpath(dirname(__FILE__) . '/..');
$includePath = get_include_path();
$includePathList = explode(PATH_SEPARATOR, $includePath);
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());
}
}
|