Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / search / SearchEngineFactory.php
blob67f500c1ce6978817928d9a89919b9eadbc6e8c8
1 <?php
3 /**
4 * Factory class for SearchEngine.
5 * Allows to create engine of the specific type.
6 */
7 class SearchEngineFactory {
9 /**
10 * Configuration for SearchEngine classes.
11 * @var SearchEngineConfig
13 private $config;
15 public function __construct( SearchEngineConfig $config ) {
16 $this->config = $config;
19 /**
20 * Create SearchEngine of the given type.
21 * @param string $type
22 * @return SearchEngine
24 public function create( $type = null ) {
25 $dbr = null;
27 $configType = $this->config->getSearchType();
28 $alternatives = $this->config->getSearchTypes();
30 if ( $type && in_array( $type, $alternatives ) ) {
31 $class = $type;
32 } elseif ( $configType !== null ) {
33 $class = $configType;
34 } else {
35 $dbr = wfGetDB( DB_SLAVE );
36 $class = $dbr->getSearchEngine();
39 $search = new $class( $dbr );
40 return $search;