Commit | Line | Data |
---|---|---|
4f102cdd | 1 | <?php |
a4685b95 S |
2 | /** |
3 | * @author Jan Altensen (Stricted) | |
4 | * @copyright 2013-2014 Jan Altensen (Stricted) | |
5 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
4f102cdd S |
6 | */ |
7 | class autoload { | |
8 | /* | |
9 | * constructor to set autoloader | |
10 | */ | |
11 | public function __construct () { | |
12 | spl_autoload_register(array('self', 'autoload')); | |
13 | } | |
14 | ||
15 | /* | |
16 | * autoload class files from namespace uses | |
17 | * | |
18 | * @param string $className | |
19 | */ | |
20 | public static function autoload ($className) { | |
21 | $namespaces = explode('\\', $className); | |
22 | if (count($namespaces) > 1) { | |
23 | array_shift($namespaces); | |
24 | $classPath = dirname(__FILE__) . '/' . implode('/', $namespaces) . '.class.php'; | |
25 | if (file_exists($classPath)) { | |
26 | require_once($classPath); | |
27 | } | |
28 | } | |
29 | } | |
30 | } | |
31 | new autoload(); | |
32 | ?> |