4 * Factory class for SearchEngine.
5 * Allows to create engine of the specific type.
7 class SearchEngineFactory
{
10 * Configuration for SearchEngine classes.
11 * @var SearchEngineConfig
15 public function __construct( SearchEngineConfig
$config ) {
16 $this->config
= $config;
20 * Create SearchEngine of the given type.
22 * @return SearchEngine
24 public function create( $type = null ) {
27 $configType = $this->config
->getSearchType();
28 $alternatives = $this->config
->getSearchTypes();
30 if ( $type && in_array( $type, $alternatives ) ) {
32 } elseif ( $configType !== null ) {
35 $dbr = wfGetDB( DB_SLAVE
);
36 $class = $dbr->getSearchEngine();
39 $search = new $class( $dbr );