MediaWiki  1.34.0
SearchResultTrait.php
Go to the documentation of this file.
1 <?php
2 
12  protected $extensionData;
13 
19  public function getExtensionData() {
20  if ( $this->extensionData ) {
21  return call_user_func( $this->extensionData );
22  } else {
23  return [];
24  }
25  }
26 
34  public function setExtensionData( $extensionData ) {
35  if ( $extensionData instanceof Closure ) {
36  $this->extensionData = $extensionData;
37  } elseif ( is_array( $extensionData ) ) {
38  wfDeprecated( __METHOD__ . ' with array argument', '1.32' );
39  $this->extensionData = function () use ( $extensionData ) {
40  return $extensionData;
41  };
42  } else {
43  $type = is_object( $extensionData )
44  ? get_class( $extensionData )
45  : gettype( $extensionData );
46  throw new \InvalidArgumentException(
47  __METHOD__ . " must be called with Closure|array, but received $type" );
48  }
49  }
50 }
SearchResultTrait
trait SearchResultTrait
Trait for SearchResult subclasses to share non-obvious behaviors or methods that rarely specialized.
Definition: SearchResultTrait.php:7
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1044
getExtensionData
getExtensionData()
Get the extension data as: augmentor name => data.
Definition: SearchResultTrait.php:19
setExtensionData
setExtensionData( $extensionData)
Set extension data for this result.
Definition: SearchResultTrait.php:34
$type
$type
Definition: testCompression.php:48