Allow SearchEngine users to access features data
authorDavid Causse <dcausse@wikimedia.org>
Fri, 27 Jan 2017 14:04:51 +0000 (15:04 +0100)
committerDavid Causse <dcausse@wikimedia.org>
Fri, 27 Jan 2017 14:12:10 +0000 (15:12 +0100)
Useful in case the client wants to re-evaluate what was set
here, or if the SearchEngine implementation wants to expose
some of its states.
In our case it allows CirrusSearch to inform SpecialSearch
that we prefer to display search results with a new experimental
layout.

Bug: T156299
Change-Id: I7f661c852ef70ea7bc9ae2959f7d6e48776a9877

includes/search/SearchEngine.php

index 0bcb07a..206067f 100644 (file)
@@ -109,6 +109,20 @@ abstract class SearchEngine {
                $this->features[$feature] = $data;
        }
 
+       /**
+        * Way to retrieve custom data set by setFeatureData
+        * or by the engine itself.
+        * @since 1.29
+        * @param string $feature feature name
+        * @return mixed the feature value or null if unset
+        */
+       public function getFeatureData( $feature ) {
+               if ( isset ( $this->features[$feature] ) ) {
+                       return $this->features[$feature];
+               }
+               return null;
+       }
+
        /**
         * When overridden in derived class, performs database-specific conversions
         * on text to be used for searching or updating search index.