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 * Loads the plugin contained in $file
*/ */
public function loadPlugin(string $file) : void{ public function loadPlugin(string $path) : void{
$description = $this->getPluginDescription($file); $description = $this->getPluginDescription($path);
if($description !== null){ if($description !== null){
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src"); $this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
} }
} }
/** /**
* Gets the PluginDescription from the file * Gets the PluginDescription from the file
*/ */
public function getPluginDescription(string $file) : ?PluginDescription{ public function getPluginDescription(string $path) : ?PluginDescription{
$pluginYmlPath = Path::join($file, "plugin.yml"); $pluginYmlPath = Path::join($path, "plugin.yml");
if(is_dir($file) && file_exists($pluginYmlPath)){ if(is_dir($path) && file_exists($pluginYmlPath)){
try{ try{
$yaml = Filesystem::fileGetContents($pluginYmlPath); $yaml = Filesystem::fileGetContents($pluginYmlPath);
}catch(\RuntimeException){ }catch(\RuntimeException){

View File

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

View File

@ -36,13 +36,13 @@ interface PluginLoader{
/** /**
* Loads the plugin contained in $file * Loads the plugin contained in $file
*/ */
public function loadPlugin(string $file) : void; public function loadPlugin(string $path) : void;
/** /**
* Gets the PluginDescription from the file * Gets the PluginDescription from the file
* @throws PluginDescriptionParseException * @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:// * 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 * Loads the plugin contained in $file
*/ */
public function loadPlugin(string $file) : void{ public function loadPlugin(string $path) : void{
include_once $file; include_once $path;
} }
/** /**
* Gets the PluginDescription from the file * Gets the PluginDescription from the file
*/ */
public function getPluginDescription(string $file) : ?PluginDescription{ public function getPluginDescription(string $path) : ?PluginDescription{
$content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $content = @file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if($content === false){ if($content === false){
return null; return null;
} }