Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit 3429238

Browse files
committed
Modified ColumnCollection to use Collection class
1 parent c364474 commit 3429238

File tree

1 file changed

+6
-62
lines changed

1 file changed

+6
-62
lines changed

src/CS/DataGridBundle/Grid/Column/ColumnCollection.php

+6-62
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,22 @@
1111

1212
namespace CS\DataGridBundle\Grid\Column;
1313

14-
use CS\DataGridBundle\Util\ArrayStack;
14+
use CS\DataGridBundle\Grid\Collection;
1515

16-
class ColumnCollection extends ArrayStack
16+
class ColumnCollection extends Collection
1717
{
1818
/**
1919
* Adds a new Column to the collection
20+
*
2021
* @param string $label
2122
* @param integer $priority
2223
*/
2324
public function add($label, $priority = 0)
2425
{
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);
5128

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);
8630

8731
return $this;
8832
}

0 commit comments

Comments
 (0)