From 479ba25ee6e4600d0c2d46869c1dff991ae2ddc9 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Tue, 18 Nov 2014 12:09:23 +0000 Subject: [PATCH] Add plugin version --- Plugin.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Plugin.php b/Plugin.php index 135fa88..a6d6ce1 100644 --- a/Plugin.php +++ b/Plugin.php @@ -51,6 +51,9 @@ use Mibew\EventDispatcher\Events; * Plugin class must implements \Mibew\Plugin\PluginInterface and can extends * \Mibew\Plugin\AbstractPlugin class. The latter contains basic functions that * can be helpfull. + * + * If the plugin extends \Mibew\Plugin\AbstractPlugin class it must implement + * only "run" and "getVersion" methods. */ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\PluginInterface { @@ -96,9 +99,6 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi /** * The main entry point of a plugin * - * If a plugin extends \Mibew\Plugin\AbstructPlugin class the only method - * that should be implemented is "run". - * * Here we can attach event listeners and do other job. */ public function run() @@ -124,6 +124,23 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi $args['css'][] = $this->getFilesPath() . '/css/styles.css'; } + /** + * Returns verision of the plugin. + * + * The version can be any string compatible with semantic version + * convention (see {@link http://semver.org/}). For example one can use the + * following versions: + * - "1.2.3" + * - "0.1.7-alpha.2" + * - "4.0.0-beta.4" + * + * @return string Plugin's version. + */ + public static function getVersion() + { + return '0.1.0'; + } + /** * Also we can add dependencies. But make sure that they were loaded BEFORE * current plugin in config.php @@ -132,8 +149,8 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi * we need to return the following array: * * return array( - * 'Abc:BestFeature', - * 'Xyz:Logger', + * 'Abc:BestFeature' => '0.2.1', + * 'Xyz:Logger' => '3.1.4', * ); * */