diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-09 07:23:18 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-09 07:23:18 +0400 |
commit | 918355e3705e258d2bdabf6a42b9ddc8fdfbfda4 (patch) | |
tree | 739a5e6b4344eabdc144feafaf3a11cd2529d324 /core/Plugin.php | |
parent | 50da9c7852080d6d6cc056dbf7030469f7e11b3a (diff) |
refs #4967 started to work on verifying plugin version during run time and before update. Not 100% tested yet, especially not the updater yet
Diffstat (limited to 'core/Plugin.php')
-rw-r--r-- | core/Plugin.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/Plugin.php b/core/Plugin.php index 3b06f7c6c6..1392fc3bc0 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -8,6 +8,7 @@ */ namespace Piwik; +use Piwik\Plugin\Dependency; use Piwik\Plugin\MetadataLoader; /** @@ -276,6 +277,34 @@ class Plugin } /** + * Detect whether there are any missing dependencies. + * + * @param null $piwikVersion Defaults to the current Piwik version + * @return bool + */ + public function hasMissingDependencies($piwikVersion = null) + { + $requirements = $this->getMissingDependencies($piwikVersion); + + return !empty($requirements); + } + + public function getMissingDependencies($piwikVersion = null) + { + if (empty($this->pluginInformation['require'])) { + return array(); + } + + $dependency = new Dependency(); + + if (!is_null($piwikVersion)) { + $dependency->setPiwikVersion($piwikVersion); + } + + return $dependency->getMissingDependencies($this->pluginInformation['require']); + } + + /** * Extracts the plugin name from a backtrace array. Returns `false` if we can't find one. * * @param array $backtrace The result of {@link debug_backtrace()} or |