Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-09-19 07:44:10 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-09-19 07:44:10 +0400
commitb46c81587598ffde15f69a657f5a981656fc3b1d (patch)
tree10b45ead6923b0b4cc689e8b0291f49f60abae48 /core
parentcc5fc7fc90c21b3a4e2bf98e028b093a91f7c738 (diff)
throw exception in case plugin defines the metadata in getInformation method and plugin json
Diffstat (limited to 'core')
-rw-r--r--core/Plugin.php20
-rw-r--r--core/Plugin/MetadataLoader.php7
2 files changed, 27 insertions, 0 deletions
diff --git a/core/Plugin.php b/core/Plugin.php
index 03db5df17c..79fca9a02b 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -55,6 +55,26 @@ class Plugin
$metadataLoader = new MetadataLoader($pluginName);
$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;
}
/**
diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php
index 60d31f895e..94d5a65cc1 100644
--- a/core/Plugin/MetadataLoader.php
+++ b/core/Plugin/MetadataLoader.php
@@ -58,6 +58,13 @@ class MetadataLoader
);
}
+ public function hasPluginJson()
+ {
+ $hasJson = $this->loadPluginInfoJson();
+
+ return !empty($hasJson);
+ }
+
private function getDefaultPluginInformation()
{
$descriptionKey = $this->pluginName . '_PluginDescription';