-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
executable file
·31 lines (22 loc) · 1020 Bytes
/
autoload.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
<?php
// helper functions
function sef_knot_autoloader($class) {
// we are just handling classes that start with 'Sef\\Knot\'
$names = explode("\\", $class);
if( ( ! isset ($names[0]) ) && ( ! isset ($names[1]) ) && ('Sef' != $names[0]) && ('Knot' != $names[1]))
return;
// remove the leading 'Sef and Knot'
array_shift($names);
array_shift($names);
// remove the last item, its the filename
$filename = array_pop($names);
// try file Components/Componentname.php for Class Sef/Knot/Components/Componentname
$file = KNOT_PATH . '/' . implode('/', $names) . '/' . $filename. '.php';
// try one path higher: file Components/Componentname.php for Class Sef/Knot/Components/Componentname
if ( ! file_exists( $file )) {
$file = KNOT_PATH . '/' . implode('/', $names) . '/' . $filename . '/' . $filename . '.php';
}
if ( ! file_exists($file))
return false;
require_once($file);
}