Merge "mw.htmlform: Fix hiding of the textbox for 'selectorother' fields on page...
[lhc/web/wiklou.git] / includes / search / SearchIndexFieldDefinition.php
index 910fd77..87d6344 100644 (file)
@@ -34,7 +34,11 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField {
        protected $subfields = [];
 
        /**
-        * SearchIndexFieldDefinition constructor.
+        * @var callable
+        */
+       private $mergeCallback;
+
+       /**
         * @param string $name Field name
         * @param int    $type Index type
         */
@@ -91,6 +95,9 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField {
         * @return SearchIndexField|false New definition or false if not mergeable.
         */
        public function merge( SearchIndexField $that ) {
+               if ( !empty( $this->mergeCallback ) ) {
+                       return call_user_func( $this->mergeCallback, $this, $that );
+               }
                // TODO: which definitions may be compatible?
                if ( ( $that instanceof self ) && $this->type === $that->type &&
                        $this->flags === $that->flags && $this->type !== self::INDEX_TYPE_NESTED
@@ -125,4 +132,18 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField {
         */
        abstract public function getMapping( SearchEngine $engine );
 
+       /**
+        * Set field-specific merge strategy.
+        * @param callable $callback
+        */
+       public function setMergeCallback( $callback ) {
+               $this->mergeCallback = $callback;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getEngineHints( SearchEngine $engine ) {
+               return [];
+       }
 }