| @@ 13-54 (lines=42) @@ | ||
| 10 | ||
| 11 | use ZfTable\Decorator\Exception; |
|
| 12 | ||
| 13 | class AttrDecorator extends AbstractCellDecorator |
|
| 14 | { |
|
| 15 | ||
| 16 | protected $attr; |
|
| 17 | ||
| 18 | ||
| 19 | /** |
|
| 20 | * Constructor |
|
| 21 | * |
|
| 22 | * @param array $attributes |
|
| 23 | * @throws Exception\InvalidArgumentException |
|
| 24 | */ |
|
| 25 | public function __construct($attributes) |
|
| 26 | { |
|
| 27 | $this->setAttr($attributes); |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Rendering decorator |
|
| 32 | * @param string $context |
|
| 33 | * @return string |
|
| 34 | */ |
|
| 35 | public function render($context) |
|
| 36 | { |
|
| 37 | if (count($this->attr) > 0) { |
|
| 38 | foreach ($this->attr as $name => $value) { |
|
| 39 | $this->getCell()->addAttr($name, $value); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | return $context; |
|
| 43 | } |
|
| 44 | ||
| 45 | public function getAttr() |
|
| 46 | { |
|
| 47 | return $this->attr; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function setAttr($attr) |
|
| 51 | { |
|
| 52 | $this->attr = $attr; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 13-54 (lines=42) @@ | ||
| 10 | ||
| 11 | use ZfTable\Decorator\Exception; |
|
| 12 | ||
| 13 | class VarAttrDecorator extends AbstractCellDecorator |
|
| 14 | { |
|
| 15 | ||
| 16 | protected $attr; |
|
| 17 | ||
| 18 | ||
| 19 | /** |
|
| 20 | * Constructor |
|
| 21 | * |
|
| 22 | * @param array $options |
|
| 23 | */ |
|
| 24 | public function __construct($options) |
|
| 25 | { |
|
| 26 | $this->setAttr($options); |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Rendering decorator |
|
| 31 | * |
|
| 32 | * @param string $context |
|
| 33 | * @return string |
|
| 34 | */ |
|
| 35 | public function render($context) |
|
| 36 | { |
|
| 37 | if (count($this->attr) > 0) { |
|
| 38 | foreach ($this->attr as $name => $value) { |
|
| 39 | $this->getCell()->addVarAttr($name, $value); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | return $context; |
|
| 43 | } |
|
| 44 | ||
| 45 | public function getAttr() |
|
| 46 | { |
|
| 47 | return $this->attr; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function setAttr($attr) |
|
| 51 | { |
|
| 52 | $this->attr = $attr; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||