MediaWiki  1.29.0
SearchIndexFieldDefinition.php
Go to the documentation of this file.
1 <?php
2 
11 abstract class SearchIndexFieldDefinition implements SearchIndexField {
17  protected $name;
23  protected $type;
29  protected $flags = 0;
34  protected $subfields = [];
35 
39  private $mergeCallback;
40 
46  public function __construct( $name, $type ) {
47  $this->name = $name;
48  $this->type = $type;
49  }
50 
55  public function getName() {
56  return $this->name;
57  }
58 
63  public function getIndexType() {
64  return $this->type;
65  }
66 
74  public function setFlag( $flag, $unset = false ) {
75  if ( $unset ) {
76  $this->flags &= ~$flag;
77  } else {
78  $this->flags |= $flag;
79  }
80  return $this;
81  }
82 
88  public function checkFlag( $flag ) {
89  return $this->flags & $flag;
90  }
91 
98  public function merge( SearchIndexField $that ) {
99  if ( !empty( $this->mergeCallback ) ) {
100  return call_user_func( $this->mergeCallback, $this, $that );
101  }
102  // TODO: which definitions may be compatible?
103  if ( ( $that instanceof self ) && $this->type === $that->type &&
104  $this->flags === $that->flags && $this->type !== self::INDEX_TYPE_NESTED
105  ) {
106  return $that;
107  }
108  return false;
109  }
110 
115  public function getSubfields() {
116  return $this->subfields;
117  }
118 
124  public function setSubfields( array $subfields ) {
125  $this->subfields = $subfields;
126  return $this;
127  }
128 
134  abstract public function getMapping( SearchEngine $engine );
135 
140  public function setMergeCallback( $callback ) {
141  $this->mergeCallback = $callback;
142  }
143 }
SearchIndexFieldDefinition\merge
merge(SearchIndexField $that)
Merge two field definitions if possible.
Definition: SearchIndexFieldDefinition.php:98
SearchIndexFieldDefinition\checkFlag
checkFlag( $flag)
Check if flag is set.
Definition: SearchIndexFieldDefinition.php:88
SearchIndexFieldDefinition\getName
getName()
Get field name.
Definition: SearchIndexFieldDefinition.php:55
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
flags
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database etc For and for historical it also represents a few features of articles that don t involve their such as access rights See also title txt Article Encapsulates access to the page table of the database The object represents a an and maintains state such as flags
Definition: design.txt:34
SearchIndexFieldDefinition\getIndexType
getIndexType()
Get index type.
Definition: SearchIndexFieldDefinition.php:63
SearchIndexFieldDefinition\$flags
int $flags
Bit flags for the field.
Definition: SearchIndexFieldDefinition.php:29
SearchIndexFieldDefinition\$name
string $name
Name of the field.
Definition: SearchIndexFieldDefinition.php:17
$engine
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2782
SearchIndexFieldDefinition\setSubfields
setSubfields(array $subfields)
Set subfields.
Definition: SearchIndexFieldDefinition.php:124
SearchIndexFieldDefinition\__construct
__construct( $name, $type)
SearchIndexFieldDefinition constructor.
Definition: SearchIndexFieldDefinition.php:46
SearchIndexFieldDefinition\getMapping
getMapping(SearchEngine $engine)
SearchIndexFieldDefinition\setMergeCallback
setMergeCallback( $callback)
Set field-specific merge strategy.
Definition: SearchIndexFieldDefinition.php:140
SearchEngine
Contain a class for special pages.
Definition: SearchEngine.php:34
SearchIndexFieldDefinition\getSubfields
getSubfields()
Get subfields.
Definition: SearchIndexFieldDefinition.php:115
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
SearchIndexFieldDefinition\$type
int $type
Type of the field, one of the constants above.
Definition: SearchIndexFieldDefinition.php:23
SearchIndexFieldDefinition
Basic infrastructure of the field definition.
Definition: SearchIndexFieldDefinition.php:11
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
SearchIndexFieldDefinition\$subfields
SearchIndexFieldDefinition[] $subfields
Subfields.
Definition: SearchIndexFieldDefinition.php:34
SearchIndexField
Definition of a mapping for the search index field.
Definition: SearchIndexField.php:6
SearchIndexFieldDefinition\setFlag
setFlag( $flag, $unset=false)
Set global flag for this field.
Definition: SearchIndexFieldDefinition.php:74
SearchIndexFieldDefinition\$mergeCallback
callable $mergeCallback
Definition: SearchIndexFieldDefinition.php:39
array
the array() calling protocol came about after MediaWiki 1.4rc1.