-
Notifications
You must be signed in to change notification settings - Fork 14
/
Autoloader.php
49 lines (43 loc) · 942 Bytes
/
Autoloader.php
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
<?php
/*
* This file is part of Spoon Library.
*
* (c) Davy Hellemans <[email protected]>
*
* For the full copyright and license information, please view the license
* file that was distributed with this source code.
*/
namespace Spoon\Template;
/**
* Autoloader for this component.
*
* @author Davy Hellemans <[email protected]>
*/
class Autoloader
{
/**
* Attempt to load this class.
*
* @param string $class The full name of the class (including namespace) to be loaded.
*/
public static function autoload($class)
{
if(strpos($class, 'Spoon\\') === false)
{
return '';
}
$file = dirname(dirname(dirname(__FILE__)));
$file .= DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
if(file_exists($file))
{
require $file;
}
}
/**
* Register this autoloader.
*/
public static function register()
{
spl_autoload_register(array(new self, 'autoload'));
}
}