MediaWiki  master
SearchEngineConfig Class Reference

Configuration handling class for SearchEngine. More...

Public Member Functions

 __construct (Config $config, Language $lang, HookContainer $hookContainer, array $mappings, UserOptionsLookup $userOptionsLookup)
 
 defaultNamespaces ()
 An array of namespaces indexes to be searched by default. More...
 
 getConfig ()
 Retrieve original config. More...
 
 getSearchMappings ()
 Returns the mappings between canonical search name and underlying PHP class. More...
 
 getSearchType ()
 Return the search engine configured in $wgSearchType, etc. More...
 
 getSearchTypes ()
 Return the search engines we support. More...
 
 namespacesAsText ( $namespaces)
 Get a list of namespace names useful for showing in tooltips and preferences. More...
 
 searchableNamespaces ()
 Make a list of searchable namespaces and their localized names. More...
 
 userNamespaces ( $user)
 Extract default namespaces to search from the given user's settings, returning a list of index numbers. More...
 

Detailed Description

Configuration handling class for SearchEngine.

Provides added service over plain configuration.

Since
1.27

Definition at line 15 of file SearchEngineConfig.php.

Constructor & Destructor Documentation

◆ __construct()

SearchEngineConfig::__construct ( Config  $config,
Language  $lang,
HookContainer  $hookContainer,
array  $mappings,
UserOptionsLookup  $userOptionsLookup 
)
Parameters
Config$config
Language$lang
HookContainer$hookContainer
array$mappings
UserOptionsLookup$userOptionsLookup

Definition at line 56 of file SearchEngineConfig.php.

References $lang.

Member Function Documentation

◆ defaultNamespaces()

SearchEngineConfig::defaultNamespaces ( )

An array of namespaces indexes to be searched by default.

Returns
int[] Namespace IDs

Definition at line 118 of file SearchEngineConfig.php.

◆ getConfig()

SearchEngineConfig::getConfig ( )

Retrieve original config.

Returns
Config

Definition at line 74 of file SearchEngineConfig.php.

◆ getSearchMappings()

SearchEngineConfig::getSearchMappings ( )

Returns the mappings between canonical search name and underlying PHP class.

Key is the canonical name (used in $wgSearchType and $wgSearchTypeAlternatives). Value is a specification for ObjectFactory.

For example to be able to use 'foobarsearch' in $wgSearchType and $wgSearchTypeAlternatives but the PHP class for 'foobarsearch' is 'MediaWiki\Extension\FoobarSearch\FoobarSearch' set:

extension.json Example:
"SearchMappings": {
"foobarsearch": { "class": "MediaWiki\\\\Extension\\\\FoobarSearch\\\\FoobarSearch" }
}
Since
1.35
Returns
array

Definition at line 165 of file SearchEngineConfig.php.

◆ getSearchType()

SearchEngineConfig::getSearchType ( )

Return the search engine configured in $wgSearchType, etc.

Returns
string|null

Definition at line 141 of file SearchEngineConfig.php.

◆ getSearchTypes()

SearchEngineConfig::getSearchTypes ( )

Return the search engines we support.

If only $wgSearchType is set, it'll be an array of just that one item.

Returns
array

Definition at line 129 of file SearchEngineConfig.php.

◆ namespacesAsText()

SearchEngineConfig::namespacesAsText (   $namespaces)

Get a list of namespace names useful for showing in tooltips and preferences.

Parameters
int[]$namespaces
Returns
string[] List of names

Definition at line 176 of file SearchEngineConfig.php.

References wfMessage().

◆ searchableNamespaces()

SearchEngineConfig::searchableNamespaces ( )

Make a list of searchable namespaces and their localized names.

Returns
string[] Namespace ID => name

Definition at line 83 of file SearchEngineConfig.php.

References NS_MAIN.

Referenced by userNamespaces().

◆ userNamespaces()

SearchEngineConfig::userNamespaces (   $user)

Extract default namespaces to search from the given user's settings, returning a list of index numbers.

Parameters
UserIdentity$user
Returns
int[]

Definition at line 102 of file SearchEngineConfig.php.

References searchableNamespaces().


The documentation for this class was generated from the following file: