MediaWiki master
SearchResultTrait.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Search;
4
5use Closure;
6use InvalidArgumentException;
7
17 protected $extensionData;
18
24 public function getExtensionData() {
25 if ( $this->extensionData ) {
26 return ( $this->extensionData )();
27 } else {
28 return [];
29 }
30 }
31
39 public function setExtensionData( $extensionData ) {
40 if ( $extensionData instanceof Closure ) {
41 $this->extensionData = $extensionData;
42 } elseif ( is_array( $extensionData ) ) {
43 wfDeprecated( __METHOD__ . ' with array argument', '1.32' );
44 $this->extensionData = static function () use ( $extensionData ) {
45 return $extensionData;
46 };
47 } else {
48 $type = get_debug_type( $extensionData );
49 throw new InvalidArgumentException(
50 __METHOD__ . " must be called with Closure|array, but received $type" );
51 }
52 }
53}
54
56class_alias( SearchResultTrait::class, 'SearchResultTrait' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition of a mapping for the search index field.
setExtensionData( $extensionData)
Set extension data for this result.
trait SearchResultTrait
Trait for SearchResult subclasses to share non-obvious behaviors or methods that rarely specialized.
getExtensionData()
Get the extension data as: augmentor name => data.