X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchIndexFieldDefinition.php;h=e3e01e8b6029549d681b1210e3ca14de642b5aee;hb=509c8d6e378a8decae43dcb27276ddae40dc1143;hp=8a06b65ed7bd3e8aebfafae7e6ccd1ff24e407c0;hpb=8a43c5afdf0736f5c60ec587da5c230cf53a8ab1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchIndexFieldDefinition.php b/includes/search/SearchIndexFieldDefinition.php index 8a06b65ed7..e3e01e8b60 100644 --- a/includes/search/SearchIndexFieldDefinition.php +++ b/includes/search/SearchIndexFieldDefinition.php @@ -33,6 +33,11 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField { */ protected $subfields = []; + /** + * @var callable + */ + private $mergeCallback; + /** * SearchIndexFieldDefinition constructor. * @param string $name Field name @@ -91,9 +96,12 @@ 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 + $this->flags === $that->flags && $this->type !== self::INDEX_TYPE_NESTED ) { return $that; } @@ -125,4 +133,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 []; + } }