MediaWiki master
MediaWiki\Search\SearchEngineConfig Class Reference

Configuration handling class for SearchEngine. More...

Public Member Functions

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

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

Configuration handling class for SearchEngine.

Provides added service over plain configuration.

Since
1.27

Definition at line 20 of file SearchEngineConfig.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Search\SearchEngineConfig::__construct ( ServiceOptions $options,
Language $language,
HookContainer $hookContainer,
array $engineMappings,
UserOptionsLookup $userOptionsLookup )

Member Function Documentation

◆ defaultNamespaces()

MediaWiki\Search\SearchEngineConfig::defaultNamespaces ( )

An array of namespaces indexes to be searched by default.

Returns
int[] Namespace IDs

Definition at line 119 of file SearchEngineConfig.php.

References MediaWiki\MainConfigNames\NamespacesToBeSearchedDefault.

◆ getConfig()

MediaWiki\Search\SearchEngineConfig::getConfig ( )

Retrieve original config.

Returns
Config
Deprecated
since 1.43, use ServiceOptions instead with DI.

Definition at line 70 of file SearchEngineConfig.php.

References wfDeprecated().

◆ getSearchMappings()

MediaWiki\Search\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" }
}
Returns
array
Since
1.35

Definition at line 166 of file SearchEngineConfig.php.

◆ getSearchType()

MediaWiki\Search\SearchEngineConfig::getSearchType ( )

Return the search engine configured in $wgSearchType, etc.

Returns
string|null

Definition at line 142 of file SearchEngineConfig.php.

References MediaWiki\MainConfigNames\SearchType.

◆ getSearchTypes()

MediaWiki\Search\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 130 of file SearchEngineConfig.php.

References MediaWiki\MainConfigNames\SearchType, and MediaWiki\MainConfigNames\SearchTypeAlternatives.

◆ namespacesAsText()

MediaWiki\Search\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 177 of file SearchEngineConfig.php.

References wfMessage().

◆ searchableNamespaces()

MediaWiki\Search\SearchEngineConfig::searchableNamespaces ( )

List searchable namespaces and their localized names (with underscores, without considering language variants).

NOTE: This is not suitable for UI text, as language variants of namespace names defined via system messages are ignored. Use {

See also
LanguageConverter::convertNamespace} instead.
Returns
array<int,string> Numeric namespace id => localized name (without language variants)

Definition at line 84 of file SearchEngineConfig.php.

References NS_MAIN.

Referenced by MediaWiki\Search\SearchEngineConfig\userNamespaces().

◆ userNamespaces()

MediaWiki\Search\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 103 of file SearchEngineConfig.php.

References MediaWiki\Search\SearchEngineConfig\searchableNamespaces().

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Search\SearchEngineConfig::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const SearchTypeAlternatives
Name constant for the SearchTypeAlternatives setting, for use with Config::get()
const SearchType
Name constant for the SearchType setting, for use with Config::get()
const NamespacesToBeSearchedDefault
Name constant for the NamespacesToBeSearchedDefault setting, for use with Config::get()
Access: internal
For use by ServiceWiring.php ONLY

Definition at line 23 of file SearchEngineConfig.php.


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