Parse plugin parameters description with the PluginManager
Plugin parameter can contain a description in their meta file under the key: parameter.<param_name>="<description>"
This commit is contained in:
parent
559315ba0a
commit
15170b5164
5 changed files with 29 additions and 13 deletions
|
@ -185,7 +185,11 @@ public function getPluginsMeta()
|
|||
continue;
|
||||
}
|
||||
|
||||
$metaData[$plugin]['parameters'][$param] = '';
|
||||
$metaData[$plugin]['parameters'][$param]['value'] = '';
|
||||
// Optional parameter description in parameter.PARAM_NAME=
|
||||
if (isset($metaData[$plugin]['parameter.'. $param])) {
|
||||
$metaData[$plugin]['parameters'][$param]['desc'] = $metaData[$plugin]['parameter.'. $param];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,13 @@ function validate_plugin_order($formData)
|
|||
}
|
||||
|
||||
/**
|
||||
* Affect plugin parameters values into plugins array.
|
||||
* Affect plugin parameters values from the ConfigManager into plugins array.
|
||||
*
|
||||
* @param mixed $plugins Plugins array ($plugins[<plugin_name>]['parameters']['param_name'] = <value>.
|
||||
* @param mixed $plugins Plugins array:
|
||||
* $plugins[<plugin_name>]['parameters'][<param_name>] = [
|
||||
* 'value' => <value>,
|
||||
* 'desc' => <description>
|
||||
* ]
|
||||
* @param mixed $conf Plugins configuration.
|
||||
*
|
||||
* @return mixed Updated $plugins array.
|
||||
|
@ -97,7 +101,7 @@ function load_plugin_parameter_values($plugins, $conf)
|
|||
|
||||
foreach ($plugin['parameters'] as $key => $param) {
|
||||
if (!empty($conf[$key])) {
|
||||
$out[$name]['parameters'][$key] = $conf[$key];
|
||||
$out[$name]['parameters'][$key]['value'] = $conf[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,14 @@ public function testGetPluginsMeta()
|
|||
$this->pluginManager->load(array(self::$pluginName));
|
||||
|
||||
$expectedParameters = array(
|
||||
'pop' => '',
|
||||
'hip' => '',
|
||||
'pop' => array(
|
||||
'value' => '',
|
||||
'desc' => 'pop description',
|
||||
),
|
||||
'hip' => array(
|
||||
'value' => '',
|
||||
'desc' => '',
|
||||
),
|
||||
);
|
||||
$meta = $this->pluginManager->getPluginsMeta();
|
||||
$this->assertEquals('test plugin', $meta[self::$pluginName]['description']);
|
||||
|
|
|
@ -101,9 +101,9 @@ public function testLoadPluginParameterValues()
|
|||
$plugins = array(
|
||||
'plugin_name' => array(
|
||||
'parameters' => array(
|
||||
'param1' => true,
|
||||
'param2' => false,
|
||||
'param3' => '',
|
||||
'param1' => array('value' => true),
|
||||
'param2' => array('value' => false),
|
||||
'param3' => array('value' => ''),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -114,8 +114,8 @@ public function testLoadPluginParameterValues()
|
|||
);
|
||||
|
||||
$result = load_plugin_parameter_values($plugins, $parameters);
|
||||
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']);
|
||||
$this->assertEquals('value2', $result['plugin_name']['parameters']['param2']);
|
||||
$this->assertEquals('', $result['plugin_name']['parameters']['param3']);
|
||||
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
|
||||
$this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']);
|
||||
$this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
description="test plugin"
|
||||
parameters="pop;hip"
|
||||
parameters="pop;hip"
|
||||
parameter.pop="pop description"
|
||||
parameter.hip=
|
Loading…
Reference in a new issue