* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_FormAttribute'); /** * Populate Form Element's Values: Remove Duplicates * * This works only for items (Enum, RadioGroup, SwitchGroup). * See if there are any values are the same and remove reoccuring records * * @version 0.1.0 * @package WB * @subpackage db */ class WBDatasource_FormAttribute_Unique extends WBDatasource_FormAttribute { /** * Configuration Parameter * @var array */ protected $config = array( ); /** * Get Attribute's Value * * Remove duplicates from list * * @param mixed $current actual attribute value * @return array */ protected function getAttributeValue($current) { if (!is_array($current)) { return $current; } if (!is_array($current[0]) || !isset($current[0]['value'])) { return $current; } $list = array(); foreach ($current as $c) { if (isset($list[$c['value']])) { continue; } $list[$c['value']] = $c; } return array_values($list); } }