OptionValueToLabel action incorrectly returns an array when single parameter is provided
OptionValueToLabel action incorrectly returns an array when single parameter is provided.
$parameters->getParameter('value');
returns an array when a single parameter is provided and thus the is_array check passes. I cannot see how the elseif statement would ever be reached. The return value is always an array. This then causes the parameter validate function to throw the exception: "requires a single value a multiple value is given".
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$value = $parameters->getParameter('value');
$option_group_id = $this->configuration->getParameter('option_group_id');
if (is_array($value)) {
$labels = array();
foreach($value as $v) {
$label = civicrm_api3('OptionValue', 'getvalue', array('return' => 'label', 'value' => $v, 'option_group_id' => $option_group_id));
$labels[] = $label;
}
$output->setParameter('value', $labels);
} elseif (!empty($value)) {
$label = civicrm_api3('OptionValue', 'getvalue', array('return' => 'label', 'value' => $value, 'option_group_id' => $option_group_id));
$output->setParameter('value', $label);
}
}
Agileware Ref: CIVICRM-2073