PluginLoader: rename parameters

This commit is contained in:
Dylan K. Taylor 2023-08-07 16:39:54 +01:00
parent e0ad39b70a
commit cb251069dd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 17 additions and 17 deletions

View File

@ -41,19 +41,19 @@ class FolderPluginLoader implements PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void{
$description = $this->getPluginDescription($file);
public function loadPlugin(string $path) : void{
$description = $this->getPluginDescription($path);
if($description !== null){
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
}
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $file) : ?PluginDescription{
$pluginYmlPath = Path::join($file, "plugin.yml");
if(is_dir($file) && file_exists($pluginYmlPath)){
public function getPluginDescription(string $path) : ?PluginDescription{
$pluginYmlPath = Path::join($path, "plugin.yml");
if(is_dir($path) && file_exists($pluginYmlPath)){
try{
$yaml = Filesystem::fileGetContents($pluginYmlPath);
}catch(\RuntimeException){

View File

@ -42,18 +42,18 @@ class PharPluginLoader implements PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void{
$description = $this->getPluginDescription($file);
public function loadPlugin(string $path) : void{
$description = $this->getPluginDescription($path);
if($description !== null){
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
}
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $file) : ?PluginDescription{
$phar = new \Phar($file);
public function getPluginDescription(string $path) : ?PluginDescription{
$phar = new \Phar($path);
if(isset($phar["plugin.yml"])){
return new PluginDescription($phar["plugin.yml"]->getContent());
}

View File

@ -36,13 +36,13 @@ interface PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void;
public function loadPlugin(string $path) : void;
/**
* Gets the PluginDescription from the file
* @throws PluginDescriptionParseException
*/
public function getPluginDescription(string $file) : ?PluginDescription;
public function getPluginDescription(string $path) : ?PluginDescription;
/**
* Returns the protocol prefix used to access files in this plugin, e.g. file://, phar://

View File

@ -46,15 +46,15 @@ class ScriptPluginLoader implements PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void{
include_once $file;
public function loadPlugin(string $path) : void{
include_once $path;
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $file) : ?PluginDescription{
$content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
public function getPluginDescription(string $path) : ?PluginDescription{
$content = @file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if($content === false){
return null;
}