MediaWiki REL1_37
SearchIndexFieldDefinition.php
Go to the documentation of this file.
1<?php
2
13
19 protected $name;
20
26 protected $type;
27
33 protected $flags = 0;
34
39 protected $subfields = [];
40
45
50 public function __construct( $name, $type ) {
51 $this->name = $name;
52 $this->type = $type;
53 }
54
59 public function getName() {
60 return $this->name;
61 }
62
66 public function getIndexType() {
67 return $this->type;
68 }
69
78 public function setFlag( $flag, $unset = false ) {
79 if ( $unset ) {
80 $this->flags &= ~$flag;
81 } else {
82 $this->flags |= $flag;
83 }
84 return $this;
85 }
86
94 public function checkFlag( $flag ) {
95 return $this->flags & $flag;
96 }
97
105 public function merge( SearchIndexField $that ) {
106 if ( !empty( $this->mergeCallback ) ) {
107 return call_user_func( $this->mergeCallback, $this, $that );
108 }
109 // TODO: which definitions may be compatible?
110 if ( ( $that instanceof self ) && $this->type === $that->type &&
111 $this->flags === $that->flags && $this->type !== self::INDEX_TYPE_NESTED
112 ) {
113 return $that;
114 }
115 return false;
116 }
117
121 public function getSubfields() {
122 return $this->subfields;
123 }
124
129 public function setSubfields( array $subfields ) {
130 $this->subfields = $subfields;
131 return $this;
132 }
133
139 abstract public function getMapping( SearchEngine $engine );
140
145 public function setMergeCallback( $callback ) {
146 $this->mergeCallback = $callback;
147 }
148
152 public function getEngineHints( SearchEngine $engine ) {
153 return [];
154 }
155}
Contain a class for special pages.
Basic infrastructure of the field definition.
SearchIndexFieldDefinition[] $subfields
Subfields.
getEngineHints(SearchEngine $engine)
A list of search engine hints for this field.Hints are usually specific to a search engine implementa...
setMergeCallback( $callback)
Set field-specific merge strategy.
getMapping(SearchEngine $engine)
merge(SearchIndexField $that)
Merge two field definitions if possible.
setFlag( $flag, $unset=false)
Set global flag for this field.
string $type
Type of the field, one of the constants above.
int $flags
Bit flags for the field.
checkFlag( $flag)
Check if flag is set.
Definition of a mapping for the search index field.