From da3f44846f3ed90bbd58b8020a463a8922a8799c Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 14 Nov 2014 13:45:38 +0000 Subject: [PATCH] Add "refresh_frequency" option --- Plugin.php | 22 +++++++++++++++++++++- README.md | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Plugin.php b/Plugin.php index 9d47f87..27ca356 100644 --- a/Plugin.php +++ b/Plugin.php @@ -37,6 +37,26 @@ use Mibew\Plugin\PluginInterface; */ class Plugin extends AbstractPlugin implements PluginInterface { + /** + * List of the plugin configs. + * + * @var array + */ + protected $config; + + /** + * Class constructor. + * + * @param array $config List of the plugin config. The following options are + * supported: + * - 'refresh_frequency': int, time in seconds between button refreshes. + * The default value is 3. + */ + public function __construct($config) + { + $this->config = $config + array('refresh_frequency' => 3); + } + /** * The plugin does not need extra initialization thus it is always ready to * work. @@ -79,7 +99,7 @@ class Plugin extends AbstractPlugin implements PluginInterface if ($args['generator'] instanceof ImageGenerator) { // Only image buttons should be refreshed $script = HTML5\html('script'); - $script->addChild($this->buildRefreshJs(3)); + $script->addChild($this->buildRefreshJs($this->config['refresh_frequency'])); $script->setAttribute('type', 'text/javascript'); $last_index = count($args['button']->getChildren()) - 1; diff --git a/README.md b/README.md index ef7b9a3..ed566ed 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,24 @@ If the "plugins" stucture looks like `plugins: []` it will become: plugins: - name: "Mibew:ButtonRefresh" + config: # Plugin's configurations are described below + refresh_frequency: 3 ``` +## Plugin's configurations + +The plugin can be configured with values in "``/configs/config.yml" file. + +### config.ignore_emoticons + +Type: `Integer` + +Default: `3` + +Specify time in seconds between button refreshes. This value is optional and can be skipped. + + ## Build from sources There are several actions one should do before use the latest version of the plugin from the repository: