public static function toIndexedArray($objects, $key, $value = null) { self::checkTypes($objects); if (is_null($value)) { $value = $key; } StringUtil::checkTypes($key, $value); if (empty($objects)) { return array(); } $result = array(); foreach ($objects as $object) { $keyString = ReflectionUtil::callNestedGetter($object, $key); $valueString = ReflectionUtil::callNestedGetter($object, $value); $result[$keyString] = $valueString; } return $result; }
private function getBeanValue($valueExpression, $rowIndex = null) { list($beanClass, $nestedProperty) = BeanUtil::getBeanAndProperties($valueExpression); try { $beanObj = BeanLocator::get($beanClass); } catch (NoSuchBeanException $e) { try { $dataSeries = $this->getFirstAncestorOfType("DataSeries"); if ($dataSeries->getVar() !== $beanClass || is_null($rowIndex)) { throw new NoSuchBeanException($beanClass); } $rows = $dataSeries->getRows(); $beanObj = $rows[$rowIndex]; } catch (NoSuchAnchestorComponentException $e) { throw new NoSuchBeanException($beanClass); } } return ReflectionUtil::callNestedGetter($beanObj, $nestedProperty); }
public function getRows() { list($beanClass, $nestedProperty) = BeanUtil::getBeanAndProperties($this->value); $beanObj = BeanLocator::get($beanClass); return ReflectionUtil::callNestedGetter($beanObj, $nestedProperty); }