Added Recursive class loading in FolderPluginLoader

This commit is contained in:
Shoghi Cervantes 2014-03-28 04:25:17 +01:00
parent a7269c7900
commit b59926bece
2 changed files with 6 additions and 11 deletions

View File

@ -96,17 +96,6 @@ namespace PocketMine {
if(file_exists($fPath)){
require_once($fPath);
}
}else{ //Try plugin
$className = array_pop($path);
if(count($path) > 0){
$path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR;
}else{
$path = "";
}
$fPath = \PocketMine\PATH . "plugins" . DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php";
if(file_exists($fPath)){
require_once($fPath);
}
}
});

View File

@ -59,6 +59,12 @@ class FolderPluginLoader implements PluginLoader{
return null;
}
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($file . "/src/")) as $fName){
if(strtolower(substr($fName, -4)) === ".php"){
include_once($fName);
}
}
$className = $description->getMain();
if(class_exists($className, true)){ //call autoloader, TODO: replace this with a specific Plugin autoload
$plugin = new $className();