blob: 6a616ba7f3eea2ffccdf6cbc6891a5a9bc919228 (
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
|
<?php
/*
* Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net>
*
* Licensed under AGPLv3
* (see COPYING for full license text)
*
*/
// Original source: http://stackoverflow.com/a/9526005/953022
class CustomAutoloader{
public function __construct()
{
spl_autoload_register(array($this, 'loader'));
}
public function loader($className)
{
$namespaces = array(
'' => [
["path" => APPPATH],
["path" => APPPATH."/third_party/mockery/library/"]
],
);
foreach ($namespaces as $namespace => $search_items) {
if ($namespace === '' || strpos($className, $namespace) === 0) {
foreach ($search_items as $search_item) {
$nameToLoad = str_replace($namespace, '', $className);
$path = $search_item['path'].str_replace('\\', DIRECTORY_SEPARATOR, $nameToLoad).'.php';
if (file_exists($path)) {
require $path;
return;
}
}
}
}
}
}
|