Merge "Resolve deprecation warnings in iw search widget"
[lhc/web/wiklou.git] / includes / search / SearchSuggestionSet.php
index ab38420..cb1f831 100644 (file)
@@ -87,6 +87,18 @@ class SearchSuggestionSet {
                return array_map( $callback, $this->suggestions );
        }
 
+       /**
+        * Filter the suggestions array
+        * @param callback $callback Callable accepting single SearchSuggestion
+        *  instance returning bool false to remove the item.
+        * @return int The number of suggestions removed
+        */
+       public function filter( $callback ) {
+               $before = count( $this->suggestions );
+               $this->suggestions = array_values( array_filter( $this->suggestions, $callback ) );
+               return $before - count( $this->suggestions );
+       }
+
        /**
         * Add a new suggestion at the end.
         * If the score of the new suggestion is greater than the worst one,