MediaWiki REL1_34
SearchResultSetTrait.php
Go to the documentation of this file.
1<?php
2
20 private $extraData = [];
21
27 public function setAugmentedData( $name, $data ) {
28 foreach ( $data as $id => $resultData ) {
29 $this->extraData[$id][$name] = $resultData;
30 }
31 }
32
37 public function augmentResult( SearchResult $result ) {
38 $id = $result->getTitle()->getArticleID();
39 if ( $id === -1 ) {
40 return;
41 }
42 $result->setExtensionData( function () use ( $id ) {
43 return $this->extraData[$id] ?? [];
44 } );
45 }
46
53 public function getOffset() {
54 return null;
55 }
56
57 final public function getIterator() {
58 return new ArrayIterator( $this->extractResults() );
59 }
60}
setAugmentedData( $name, $data)
Sets augmented data for result set.
augmentResult(SearchResult $result)
Returns extra data for specific result and store it in SearchResult object.
NOTE: this class is being refactored into an abstract base class.
trait SearchResultSetTrait
Trait useful for SearchResultSet implementations.