|
11 | 11 |
|
12 | 12 | namespace CS\DataGridBundle\Grid\Column;
|
13 | 13 |
|
14 |
| -use CS\DataGridBundle\Util\ArrayStack; |
| 14 | +use CS\DataGridBundle\Grid\Collection; |
15 | 15 |
|
16 |
| -class ColumnCollection extends ArrayStack |
| 16 | +class ColumnCollection extends Collection |
17 | 17 | {
|
18 | 18 | /**
|
19 | 19 | * Adds a new Column to the collection
|
| 20 | + * |
20 | 21 | * @param string $label
|
21 | 22 | * @param integer $priority
|
22 | 23 | */
|
23 | 24 | public function add($label, $priority = 0)
|
24 | 25 | {
|
25 |
| - $this->_data[$priority] = new Column($label); |
26 |
| - |
27 |
| - return $this; |
28 |
| - } |
29 |
| - |
30 |
| - /** |
31 |
| - * Removes a column from from the grid |
32 |
| - * |
33 |
| - * @param mixed $columns |
34 |
| - */ |
35 |
| - public function remove($columns) |
36 |
| - { |
37 |
| - $columns = is_array($columns) ? $columns : arraya($columns); |
38 |
| - |
39 |
| - if (count($this->_data) > 0) { |
40 |
| - foreach ($this->_data as $key => $data) { |
41 |
| - foreach ($columns as $label) { |
42 |
| - if (strtolower($data->getLabel()) === strtolower($label)) { |
43 |
| - unset($this->_data[$key]); |
44 |
| - } |
45 |
| - } |
46 |
| - } |
47 |
| - } |
48 |
| - |
49 |
| - return $this; |
50 |
| - } |
| 26 | + // TODO: get column class from configuration |
| 27 | + $column = new Column ($label); |
51 | 28 |
|
52 |
| - /** |
53 |
| - * Moves a column to another position |
54 |
| - * |
55 |
| - * @param string $label |
56 |
| - * @param integer $position |
57 |
| - * @return ColumnCollection |
58 |
| - */ |
59 |
| - public function move($label, $position) |
60 |
| - { |
61 |
| - if (count($this->_data) > 0) { |
62 |
| - foreach ($this->_data as $key => $data) { |
63 |
| - if (strtolower($data->getLabel()) === strtolower($label)) { |
64 |
| - unset($this->_data[$key]); |
65 |
| - $this->_data[$position] = $data; |
66 |
| - } |
67 |
| - } |
68 |
| - } |
69 |
| - |
70 |
| - return $this; |
71 |
| - } |
72 |
| - |
73 |
| - /** |
74 |
| - * Adds columns recursively |
75 |
| - * |
76 |
| - * @param array $data |
77 |
| - * @return ColumnCollection |
78 |
| - */ |
79 |
| - public function addRecursive($data = array()) |
80 |
| - { |
81 |
| - if (is_array($data) && !empty($data)) { |
82 |
| - foreach ($data as $key => $column) { |
83 |
| - $this->add($column, $key); |
84 |
| - } |
85 |
| - } |
| 29 | + $this->offsetSet($priority, $column); |
86 | 30 |
|
87 | 31 | return $this;
|
88 | 32 | }
|
|
0 commit comments