| 1 |
<?php |
| 2 |
/** |
| 3 |
* Libraries autoload for DecaLog. |
| 4 |
* |
| 5 |
* @package Libraries |
| 6 |
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
spl_autoload_register( |
| 11 |
function ( $class ) { |
| 12 |
$file = ''; |
| 13 |
foreach ( Decalog\Library\Libraries::get_psr4() as $library ) { |
| 14 |
$len = strlen( $library['prefix'] ); |
| 15 |
if ( strncmp( $library['prefix'], $class, $len ) === 0 ) { |
| 16 |
$file = $library['base'] . str_replace( '\\', '/', substr( $class, $len ) ) . '.php'; |
| 17 |
} |
| 18 |
} |
| 19 |
if ( '' === $file ) { |
| 20 |
foreach ( Decalog\Library\Libraries::get_mono() as $library ) { |
| 21 |
if ( $library['detect'] === $class ) { |
| 22 |
$file = $library['base'] . $library['detect'] . '.php'; |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
if ( '' !== $file ) { |
| 27 |
if ( file_exists( $file ) ) { |
| 28 |
include_once $file; |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
); |
| 33 |
|