/** * {@inheritdoc} */ public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view) { $value = array(); $values = $view->getValue(); if (($emptyValue = $column->getOption('empty_value')) !== null) { $values = $this->populateValues($values, $emptyValue); } $glue = $column->getOption('value_glue'); $format = $column->getOption('value_format'); foreach ($values as $val) { $objectValue = null; if (isset($glue) && !isset($format)) { $objectValue = implode($glue, $val); } if (isset($format)) { if (isset($glue)) { $formatedValues = array(); foreach ($val as $fieldValue) { $formatedValues[] = sprintf($format, $fieldValue); } $objectValue = implode($glue, $formatedValues); } else { $objectValue = vsprintf($format, $val); } } $value[] = $objectValue; } $value = implode($column->getOption('glue_multiple'), $value); $view->setValue($value); }
/** * {@inheritdoc} */ public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view) { $this->validateEmptyValueOption($column); $value = $this->populateValue($view->getValue(), $column->getOption('empty_value')); $glue = $column->getOption('value_glue'); $format = $column->getOption('value_format'); $value = $this->formatValue($value, $format, $glue); if (!isset($glue, $format) && is_array($value)) { throw new \InvalidArgumentException(sprintf('At least one of "format" or "glue" option is missing in column: "%s".', $column->getName())); } $view->setValue($value); }