Page MenuHomePhabricator

D13572.id32807.diff
No OneTemporary

D13572.id32807.diff

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 $filterNull = false;
private $uniqueMethod;
private $sortMethod;
@@ -75,12 +76,15 @@
*
* You must provide a method here to use @{method:setExpandMethod}.
*
- * @param string Name of the unique key method.
+ * @param string Name of the unique key method.
+ * @param bool If true, then classes which return `null` will be filtered
+ * from the results.
* @return this
* @task config
*/
- public function setUniqueMethod($unique_method) {
+ public function setUniqueMethod($unique_method, $filter_null = false) {
$this->uniqueMethod = $unique_method;
+ $this->filterNull = $filter_null;
return $this;
}
@@ -224,6 +228,11 @@
$map = array();
foreach ($list as $object) {
$key = call_user_func(array($object, $unique));
+
+ if ($key === null && $this->filterNull) {
+ continue;
+ }
+
if (empty($map[$key])) {
$map[$key] = $object;
continue;

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 6:19 AM (16 h, 16 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7694778
Default Alt Text
D13572.id32807.diff (1 KB)

Event Timeline