Skip to content
Extraits de code Groupes Projets
Valider b46c8158 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

throw exception in case plugin defines the metadata in getInformation method and plugin json

parent cc5fc7fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -55,6 +55,26 @@ class Plugin ...@@ -55,6 +55,26 @@ class Plugin
$metadataLoader = new MetadataLoader($pluginName); $metadataLoader = new MetadataLoader($pluginName);
$this->pluginInformation = $metadataLoader->load(); $this->pluginInformation = $metadataLoader->load();
if ($this->hasDefinedPluginInformationInPluginClass() && $metadataLoader->hasPluginJson()) {
throw new \Exception('Plugin ' . $pluginName . ' has defined the method getInformation() and as well as having a plugin.json file. Please delete the getInformation() method from the plugin class.');
}
}
private function hasDefinedPluginInformationInPluginClass()
{
$myClassName = get_class();
$pluginClassName = get_class($this);
if ($pluginClassName == $myClassName) {
// plugin has not defined its own class
return false;
}
$foo = new \ReflectionMethod(get_class($this), 'getInformation');
$declaringClass = $foo->getDeclaringClass()->getName();
return $declaringClass != $myClassName;
} }
/** /**
......
...@@ -58,6 +58,13 @@ class MetadataLoader ...@@ -58,6 +58,13 @@ class MetadataLoader
); );
} }
public function hasPluginJson()
{
$hasJson = $this->loadPluginInfoJson();
return !empty($hasJson);
}
private function getDefaultPluginInformation() private function getDefaultPluginInformation()
{ {
$descriptionKey = $this->pluginName . '_PluginDescription'; $descriptionKey = $this->pluginName . '_PluginDescription';
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter