-
Notifications
You must be signed in to change notification settings - Fork 62
/
autoload.php
38 lines (32 loc) · 1 KB
/
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
32
33
34
35
36
37
38
<?php
namespace StoutLogic\AcfBuilder;
/**
* Autoloader for use without composer.
*
* Simply require this file somewhere in your code.
*
* To learn more about PHP namespaces see:
* http://php.net/manual/en/language.namespaces.php
*
* To learn more about autoloading, see
* http://php.net/manual/en/function.autoload.php
*
* If your project is using composer, ignore this file.
* To learn more about composer see:
* https://getcomposer.org and http://composer.rarst.net
*/
spl_autoload_register(function($cls) {
$cls = ltrim($cls, '\\');
if (strpos($cls, __NAMESPACE__) !== 0) {
return;
}
$classWithoutBaseNamespace = str_replace(__NAMESPACE__, '', $cls);
// Load files from 'src' directory based on their class name without
// the StoutLogic\AcfBuilder namespace.
$path = dirname(__FILE__).
DIRECTORY_SEPARATOR.
'src'.
str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutBaseNamespace).
'.php';
require_once($path);
});