Fixed plugin loaders trying to load plugins they aren't able to load

closes #2125

This is an API break for things implementing the PluginLoader interface.
This commit is contained in:
Dylan K. Taylor 2018-04-09 15:54:20 +01:00
parent 476ac39988
commit 5f52e00213
5 changed files with 23 additions and 1 deletions

View File

@ -101,6 +101,11 @@ class PharPluginLoader implements PluginLoader{
return "/\\.phar$/i";
}
public function canLoadPlugin(string $path) : bool{
$ext = ".phar";
return is_file($path) and substr($path, -strlen($ext)) === $ext;
}
/**
* @param PluginBase $plugin
* @param PluginDescription $description

View File

@ -53,6 +53,15 @@ interface PluginLoader{
*/
public function getPluginFilters() : string;
/**
* Returns whether this PluginLoader can load the plugin in the given path.
*
* @param string $path
*
* @return bool
*/
public function canLoadPlugin(string $path) : bool;
/**
* @param Plugin $plugin
*

View File

@ -210,6 +210,9 @@ class PluginManager{
continue;
}
$file = $directory . $file;
if(!$loader->canLoadPlugin($file)){
continue;
}
try{
$description = $loader->getPluginDescription($file);
if($description instanceof PluginDescription){

View File

@ -124,6 +124,11 @@ class ScriptPluginLoader implements PluginLoader{
return "/\\.php$/i";
}
public function canLoadPlugin(string $path) : bool{
$ext = ".php";
return is_file($path) and substr($path, -strlen($ext)) === $ext;
}
/**
* @param PluginBase $plugin
* @param PluginDescription $description

@ -1 +1 @@
Subproject commit 96fa93a3b4ee417ea5aff9ebb4e85d1fc6c7f960
Subproject commit a897b84de445069dee898eaed95a9ff708a19383