Merge "docs: Fix typo"
[mediawiki.git] / includes / search / PerRowAugmentor.php
blob788f23b37674aca116220be4e96fb62ec3e493b0
1 <?php
3 /**
4 * Perform augmentation of each row and return composite result,
5 * indexed by ID.
6 */
7 class PerRowAugmentor implements ResultSetAugmentor {
9 private ResultAugmentor $rowAugmentor;
11 /**
12 * @param ResultAugmentor $augmentor Per-result augmentor to use.
14 public function __construct( ResultAugmentor $augmentor ) {
15 $this->rowAugmentor = $augmentor;
18 /**
19 * Produce data to augment search result set.
20 * @param ISearchResultSet $resultSet
21 * @return array Data for all results
23 public function augmentAll( ISearchResultSet $resultSet ) {
24 $data = [];
25 foreach ( $resultSet->extractResults() as $result ) {
26 $id = $result->getTitle()->getArticleID();
27 if ( !$id ) {
28 continue;
30 $data[$id] = $this->rowAugmentor->augment( $result );
32 return $data;