mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
search for include path
This commit is contained in:
parent
0bec263d78
commit
6a6351a275
|
|
@ -34,7 +34,6 @@ final class Autoloader
|
||||||
*/
|
*/
|
||||||
private static $paths = [
|
private static $paths = [
|
||||||
__DIR__ . '/../',
|
__DIR__ . '/../',
|
||||||
__DIR__ . '/../../',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,10 +60,34 @@ final class Autoloader
|
||||||
self::$paths[] = $path;
|
self::$paths[] = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find include paths for class
|
||||||
|
*
|
||||||
|
* @param string $class Class name
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function findPaths(string $class) : array
|
||||||
|
{
|
||||||
|
$found = [];
|
||||||
|
$class = \ltrim($class, '\\');
|
||||||
|
$class = \str_replace(['_', '\\'], '/', $class);
|
||||||
|
|
||||||
|
foreach (self::$paths as $path) {
|
||||||
|
if (\is_file($file = $path . $class . '.php')) {
|
||||||
|
$found[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $found;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loading classes by namespace + class name.
|
* Loading classes by namespace + class name.
|
||||||
*
|
*
|
||||||
* @param string $class Class path
|
* @param string $class Class name
|
||||||
*
|
*
|
||||||
* @example Autoloader::defaultAutoloader('\phpOMS\Autoloader') // void
|
* @example Autoloader::defaultAutoloader('\phpOMS\Autoloader') // void
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user