Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / includes / search / PerRowAugmentor.php
1 <?php
2
3 /**
4 * Perform augmentation of each row and return composite result,
5 * indexed by ID.
6 */
7 class PerRowAugmentor implements ResultSetAugmentor {
8
9 /**
10 * @var ResultAugmentor
11 */
12 private $rowAugmentor;
13
14 /**
15 * PerRowAugmentor constructor.
16 * @param ResultAugmentor $augmentor Per-result augmentor to use.
17 */
18 public function __construct( ResultAugmentor $augmentor ) {
19 $this->rowAugmentor = $augmentor;
20 }
21
22 /**
23 * Produce data to augment search result set.
24 * @param SearchResultSet $resultSet
25 * @return array Data for all results
26 */
27 public function augmentAll( SearchResultSet $resultSet ) {
28 $data = [];
29 foreach ( $resultSet->extractResults() as $result ) {
30 $id = $result->getTitle()->getArticleID();
31 if ( !$id ) {
32 continue;
33 }
34 $data[$id] = $this->rowAugmentor->augment( $result );
35 }
36 return $data;
37 }
38 }