Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CirrusSearchConfiguration | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| getWBCSConfig | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| isWBCSEnabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace Wikibase\Search\Elastic\Hooks; |
| 6 | |
| 7 | use MediaWiki\MediaWikiServices; |
| 8 | use Wikibase\Search\Elastic\WikibaseSearchConfig; |
| 9 | |
| 10 | /** |
| 11 | * Hooks for Wikibase search. |
| 12 | */ |
| 13 | class CirrusSearchConfiguration { |
| 14 | |
| 15 | /** |
| 16 | * We need to access the `WikibaseCirrusSearch` configuration from early-initialization |
| 17 | * hook contexts where it would not be possible to inject the ConfigFactory service. |
| 18 | * |
| 19 | * Fortunately, static access to the ConfigFactory is allowed under the |
| 20 | * {@link \MediaWiki\Hook\MediaWikiServicesHook::onMediaWikiServices() MediaWikiServicesHook rules}. |
| 21 | * |
| 22 | * @return WikibaseSearchConfig |
| 23 | * @suppress PhanTypeMismatchReturnSuperType |
| 24 | */ |
| 25 | public static function getWBCSConfig(): WikibaseSearchConfig { |
| 26 | return MediaWikiServices::getInstance()->getConfigFactory() |
| 27 | ->makeConfig( 'WikibaseCirrusSearch' ); |
| 28 | } |
| 29 | |
| 30 | public static function isWBCSEnabled(): bool { |
| 31 | return self::getWBCSConfig()->enabled() ?? false; |
| 32 | } |
| 33 | |
| 34 | } |