Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * @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;
 }
Пример #3
0
 /**
  * @param Column $column
  *
  * @return string
  */
 protected function getColumnAttributes(Column $column)
 {
     $options = $column->getOptions();
     if (isset($options['attributes']) && is_array($options['attributes'])) {
         $attribute = '%s="%s"';
         $attributes = [];
         foreach ($options['attributes'] as $name => $value) {
             $attributes[] = vsprintf($attribute, [$name, $value]);
         }
         return implode(' ', $attributes);
     }
     return '';
 }
Пример #4
0
 /**
  * @param string $key
  * @param string $property
  */
 public function __construct($key, $property)
 {
     $this->property = $property;
     parent::__construct($key);
 }
 /**
  * @param Column $column
  */
 public function __construct(Column $column)
 {
     $message = sprintf('A column with [key=%s] has already been added.', $column->getKey());
     parent::__construct($message);
 }
Пример #6
0
 /**
  * @param string $column
  * @param        $alias
  */
 public function __construct($column, $alias)
 {
     parent::__construct($column);
     $this->alias = $alias;
 }