/** * Ajoute une colonne à la table * * @param Column $column * * @return $this * @throws ColumnAlreadyAddedException */ public function add(Column $column) { try { $this->getColumnByKey($column->getKey()); } catch (ColumnKeyNotFoundException $cknf) { if ($column instanceof ServiceLocatorAwareInterface) { $column->setServiceLocator($this->getServiceLocator()); } $this->columns[$column->getKey()] = $column; return $this; } throw new ColumnAlreadyAddedException($column); }
/** * @param Column $column * @param mixed $row * * @return mixed|string */ protected function getValueForRow(Column $column, $row) { if ($column instanceof Column\Property) { // This one only gets the property $value = $row->{'get' . ucfirst($column->getProperty())}(); } elseif ($column instanceof Column\Select) { // And this one is used to build the query $value = $row->{'get' . ucfirst($column->getKey())}(); } elseif ($column instanceof Column\Index) { $value = $row[$column->getKey()]; } else { $value = $column->getKey(); } foreach ($column->getDecorators() as $decorator) { $decorator = clone $decorator; if ($decorator instanceof RowAwareInterface) { $decorator->setRow($row); } $value = $this->applyDecoratorOnValue($decorator, $value); } return $value; }
/** * @param Column $column */ public function __construct(Column $column) { $message = sprintf('A column with [key=%s] has already been added.', $column->getKey()); parent::__construct($message); }