summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/insertables/CombinedInsertablesSuggester.php
blob: 5f3c468a014edc3d11170d3350c7f574a027f462 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

/**
 * A class to combine multiple insertables suggesters.
 */
class CombinedInsertablesSuggester implements InsertablesSuggester {

	/**
	 * @var InsertablesSuggester[]
	 */
	protected $suggesters = [];

	/**
	 * @param InsertablesSuggester[] $suggesters Array of InsertablesSuggester objects to combine.
	 */
	public function __construct( $suggesters = [] ) {
		$this->suggesters = $suggesters;
	}

	public function getInsertables( $text ) {
		$insertables = [];
		foreach ( $this->suggesters as $suggester ) {
			$new = $suggester->getInsertables( $text );
			$insertables = array_merge( $insertables, $new );
		}

		return array_unique( $insertables, SORT_REGULAR );
	}
}