diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-06 00:40:53 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-06 11:02:59 +0400 |
commit | 3528547ccf8e7c2a354b31be2b7e0f4c7ebcc093 (patch) | |
tree | 3a8f1533cfc693ffafd1b82854a4d17e6b774584 /core/DataTable/Filter/ColumnDelete.php | |
parent | 1380c33bc5b9996a09e3c5b3b5a5eac808c7b320 (diff) |
refs #5896 tests are showing converting an array to a dataTable and run the filters on it will not work. Instead run the filters directly on the array. Therefore, to not have duplicated code the dataTable and row can be now treated as an array and we access them like an array in the ColumnDelete filter which will be for now the only filter is applied on arrays
Diffstat (limited to 'core/DataTable/Filter/ColumnDelete.php')
-rw-r--r-- | core/DataTable/Filter/ColumnDelete.php | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/core/DataTable/Filter/ColumnDelete.php b/core/DataTable/Filter/ColumnDelete.php index 976519c6fa..f9f9773af8 100644 --- a/core/DataTable/Filter/ColumnDelete.php +++ b/core/DataTable/Filter/ColumnDelete.php @@ -100,15 +100,16 @@ class ColumnDelete extends BaseFilter // remove columns specified in $this->columnsToRemove if (!empty($this->columnsToRemove)) { - foreach ($table->getRows() as $row) { + foreach ($table as $row) { foreach ($this->columnsToRemove as $column) { if ($this->deleteIfZeroOnly) { - $value = $row->getColumn($column); + $value = $row[$column]; if ($value === false || !empty($value)) { continue; } } - $row->deleteColumn($column); + + unset($row[$column]); } } @@ -117,8 +118,8 @@ class ColumnDelete extends BaseFilter // remove columns not specified in $columnsToKeep if (!empty($this->columnsToKeep)) { - foreach ($table->getRows() as $row) { - foreach ($row->getColumns() as $name => $value) { + foreach ($table as $row) { + foreach ($row as $name => $value) { $keep = false; // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP @@ -132,7 +133,7 @@ class ColumnDelete extends BaseFilter && $name != 'label' // label cannot be removed via whitelisting && !isset($this->columnsToKeep[$name]) ) { - $row->deleteColumn($name); + unset($row[$name]); } } } @@ -141,10 +142,12 @@ class ColumnDelete extends BaseFilter } // recurse - if ($recurse) { - foreach ($table->getRows() as $row) { + if ($recurse && !is_array($table)) { + foreach ($table as $row) { $this->filterSubTable($row); } } + + return $table; } } |