From 57ea5d6d5a701a74ea25fc9c46e4256e35e4396c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 17 Aug 2015 12:53:17 +0200 Subject: [PATCH] DataView: Use a more flexible way to provide filter columns refs #9029 --- .../library/Monitoring/DataView/DataView.php | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 181c159ab..1e5928fda 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -35,6 +35,13 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite protected $isSorted = false; + /** + * The cache for all filter columns + * + * @var array + */ + protected $filterColumns; + /** * Create a new view * @@ -174,19 +181,45 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite } /** - * Check whether the given column is a valid filter column, i.e. the view actually provides the column or it's - * a non-queryable filter column + * Check whether the given column is a valid filter column * - * @param string $column + * @param string $column * * @return bool */ public function isValidFilterTarget($column) { - return in_array($column, $this->getColumns()) || in_array($column, $this->getFilterColumns()); + return in_array($column, $this->getFilterColumns()); } + /** + * Return all filter columns with their optional label as key + * + * This will merge the results of self::getColumns(), self::getStaticFilterColumns() and + * self::getDynamicFilterColumns() *once*. (i.e. subsequent calls of this function will + * return the same result.) + * + * @return array + */ public function getFilterColumns() + { + if ($this->filterColumns === null) { + $this->filterColumns = array_merge( + $this->getColumns(), + $this->getStaticFilterColumns(), + $this->getDynamicFilterColumns() + ); + } + + return $this->filterColumns; + } + + /** + * Return all static filter columns + * + * @return array + */ + public function getStaticFilterColumns() { return array(); }