|
16 | 16 | define('PFC_BIN_DIR', __DIR__ . '/../bin/'); |
17 | 17 |
|
18 | 18 | /** |
19 | | - * Register Autoload |
| 19 | + * Register PhpFastCache Autoload |
| 20 | + */ |
| 21 | +set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . DIRECTORY_SEPARATOR); |
| 22 | +spl_autoload_register(); |
| 23 | + |
| 24 | +/** |
| 25 | + * Register PhpFastCache |
| 26 | + * embedded-libraries Autoload |
20 | 27 | */ |
21 | 28 | spl_autoload_register(function ($entity) { |
22 | | - $module = explode('\\', $entity, 2); |
23 | | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
24 | | - /** |
25 | | - * Not a part of phpFastCache file |
26 | | - * then we return here. |
27 | | - */ |
28 | | - return; |
29 | | - } else if (strpos($entity, 'Psr\Cache') === 0) { |
| 29 | + /** |
| 30 | + * Attempting to load Psr\Cache |
| 31 | + */ |
| 32 | + if (strpos($entity, 'Psr\Cache') === 0) { |
30 | 33 | $path = PFC_BIN_DIR . 'legacy/Psr/Cache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT; |
31 | 34 |
|
32 | 35 | if (is_readable($path)) { |
|
35 | 38 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
36 | 39 | } |
37 | 40 | return; |
38 | | - } else if (strpos($entity, 'Psr\SimpleCache') === 0) { |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Attempting to load Psr\SimpleCache |
| 45 | + */ |
| 46 | + if (strpos($entity, 'Psr\SimpleCache') === 0) { |
39 | 47 | $path = PFC_BIN_DIR . 'legacy/Psr/SimpleCache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT; |
40 | 48 |
|
41 | 49 | if (is_readable($path)) { |
|
45 | 53 | } |
46 | 54 | return; |
47 | 55 | } |
48 | | - |
49 | | - $entity = str_replace('\\', '/', $entity); |
50 | | - $path = __DIR__ . '/' . $entity . '.' . PFC_PHP_EXT; |
51 | | - |
52 | | - if (is_readable($path)) { |
53 | | - require_once $path; |
54 | | - } |
55 | 56 | }); |
56 | 57 |
|
57 | 58 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
|
0 commit comments