diff --git a/src/symbols/PhutilClassMapQuery.php b/src/symbols/PhutilClassMapQuery.php --- a/src/symbols/PhutilClassMapQuery.php +++ b/src/symbols/PhutilClassMapQuery.php @@ -41,6 +41,7 @@ private $ancestorClass; private $expandMethod; + private $filterMethod; private $filterNull = false; private $uniqueMethod; private $sortMethod; @@ -148,6 +149,19 @@ } + /** + * Provide a method to filter the map. + * + * @param string Name of the filtering method. + * @return this + * @task config + */ + public function setFilterMethod($filter_method) { + $this->filterMethod = $filter_method; + return $this; + } + + /* -( Executing the Query )------------------------------------------------ */ @@ -191,6 +205,7 @@ } $expand = $this->expandMethod; + $filter = $this->filterMethod; $unique = $this->uniqueMethod; $sort = $this->sortMethod; @@ -253,6 +268,11 @@ $map = $list; } + // Apply the "filter" mechanism, if it is configured. + if (strlen($filter)) { + $map = mfilter($map, $filter); + } + // Apply the "sort" mechanism, if it is configured. if (strlen($sort)) { $map = msort($map, $sort);