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; + } +}