dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git]
/
includes
/
search
/
SearchIndexFieldDefinition.php
diff --git
a/includes/search/SearchIndexFieldDefinition.php
b/includes/search/SearchIndexFieldDefinition.php
index
8a06b65
..
04344fd
100644
(file)
--- a/
includes/search/SearchIndexFieldDefinition.php
+++ b/
includes/search/SearchIndexFieldDefinition.php
@@
-33,6
+33,11
@@
abstract class SearchIndexFieldDefinition implements SearchIndexField {
*/
protected $subfields = [];
*/
protected $subfields = [];
+ /**
+ * @var callable
+ */
+ private $mergeCallback;
+
/**
* SearchIndexFieldDefinition constructor.
* @param string $name Field name
/**
* 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 ) {
* @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 &&
// 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;
}
) {
return $that;
}
@@
-125,4
+133,11
@@
abstract class SearchIndexFieldDefinition implements SearchIndexField {
*/
abstract public function getMapping( SearchEngine $engine );
*/
abstract public function getMapping( SearchEngine $engine );
+ /**
+ * Set field-specific merge strategy.
+ * @param callable $callback
+ */
+ public function setMergeCallback( $callback ) {
+ $this->mergeCallback = $callback;
+ }
}
}