protected function registerClassAutoloader($paths)
{
spl_autoload_register(function ($class) use($paths) {
// traverse in registered plugin paths
foreach ((array) array_keys($paths) as $namespace) {
if ($namespace != '' && mb_strpos($class, $namespace) === 0) {
// parse real file path
$path = $paths[$namespace] . Str::replaceFirst($namespace, '', $class) . ".php";
$path = str_replace('\\', '/', $path);
if (file_exists($path)) {
// include class file if it exists
include $path;
}
}
}
});
}