From a4361fe8cecbf05ca9b0dfe079f7b1cd7c9a64b6 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 24 Nov 2014 10:37:08 +0000 Subject: [PATCH] Create plugin info wrapper --- .../libs/classes/Mibew/Plugin/PluginInfo.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/mibew/libs/classes/Mibew/Plugin/PluginInfo.php diff --git a/src/mibew/libs/classes/Mibew/Plugin/PluginInfo.php b/src/mibew/libs/classes/Mibew/Plugin/PluginInfo.php new file mode 100644 index 00000000..78ae32f6 --- /dev/null +++ b/src/mibew/libs/classes/Mibew/Plugin/PluginInfo.php @@ -0,0 +1,122 @@ +pluginName = $plugin_name; + } + + /** + * Returns fully qualified plugin's class. + * + * @return string + */ + public function getClass() + { + if (is_null($this->pluginClass)) { + $this->pluginClass = Utils::getPluginClassName($this->pluginName); + } + + return $this->pluginClass; + } + + /** + * Returns name of the plugin. + * + * @return string + */ + public function getName() + { + return $this->pluginName; + } + + /** + * Returns current version of the plugin. + * + * @return string + */ + public function getVersion() + { + return call_user_func(array($this->getClass(), 'getVersion')); + } + + /** + * Returns dependencies of the plugin. + * + * @return array Dependencies list. See + * {@link \Mibew\Plugin\PluginInterface::getDependencies()} for detail of + * array structure. + */ + public function getDependencies() + { + return call_user_func(array($this->getClass(), 'getDependencies')); + } + + /** + * Returns list of dependent plugins. + * + * @return array List of plugins names. + */ + public function getDependentPlugins() + { + $dependent_plugins = array(); + foreach (Utils::discoverPlugins() as $plugin_name) { + $plugin = new PluginInfo($plugin_name); + if (array_key_exists($this->getName(), $plugin->getDependencies())) { + $dependent_plugins[] = $plugin_name; + } + } + + return $dependent_plugins; + } +}