Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / includes / search / PerRowAugmentor.php
blob8eb8b17c111061d1cf8c393a42a33be5d34af938
1 <?php
3 /**
4 * Perform augmentation of each row and return composite result,
5 * indexed by ID.
6 */
7 class PerRowAugmentor implements ResultSetAugmentor {
9 /**
10 * @var ResultAugmentor
12 private $rowAugmentor;
14 /**
15 * PerRowAugmentor constructor.
16 * @param ResultAugmentor $augmentor Per-result augmentor to use.
18 public function __construct( ResultAugmentor $augmentor ) {
19 $this->rowAugmentor = $augmentor;
22 /**
23 * Produce data to augment search result set.
24 * @param SearchResultSet $resultSet
25 * @return array Data for all results
27 public function augmentAll( SearchResultSet $resultSet ) {
28 $data = [];
29 foreach ( $resultSet->extractResults() as $result ) {
30 $id = $result->getTitle()->getArticleID();
31 if ( !$id ) {
32 continue;
34 $data[$id] = $this->rowAugmentor->augment( $result );
36 return $data;