Skip to content

Commit

Permalink
refactor(core): ♻️ use MainConfigNames constants instead of string li…
Browse files Browse the repository at this point in the history
…terals

Related: T305805
  • Loading branch information
alistair3149 committed May 7, 2024
1 parent 06e7a77 commit 9110ef1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions includes/Api/ApiWebappManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace MediaWiki\Skins\Citizen\Api;

use ApiBase;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Title\Title;
use SpecialPage;
Expand All @@ -44,11 +45,11 @@ public function execute() {
$config = $this->getConfig();
$resultObj = $this->getResult();
$resultObj->addValue( null, 'dir', $services->getContentLanguage()->getDir() );
$resultObj->addValue( null, 'lang', $config->get( 'LanguageCode' ) );
$resultObj->addValue( null, 'name', $config->get( 'Sitename' ) );
$resultObj->addValue( null, 'lang', $config->get( MainConfigNames::LanguageCode ) );
$resultObj->addValue( null, 'name', $config->get( MainConfigNames::Sitename ) );
// Need to set it manually because the default from start_url does not include script namespace
// E.g. index.php URLs will be thrown out of the PWA
$resultObj->addValue( null, 'scope', $config->get( 'Server' ) . '/' );
$resultObj->addValue( null, 'scope', $config->get( MainConfigNames::Server ) . '/' );
$resultObj->addValue( null, 'icons', $this->getIcons( $config, $services ) );
$resultObj->addValue( null, 'display', 'standalone' );
$resultObj->addValue( null, 'orientation', 'portrait' );
Expand All @@ -71,7 +72,7 @@ public function execute() {
*/
private function getIcons( $config, $services ) {
$icons = [];
$logos = $config->get( 'Logos' );
$logos = $config->get( MainConfigNames::Logos );

// That really shouldn't happen
if ( $logos !== false ) {
Expand Down
7 changes: 4 additions & 3 deletions includes/Hooks/ResourceLoaderHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use Config;
use ExtensionRegistry;
use MediaWiki\MainConfigNames;
use MediaWiki\ResourceLoader as RL;

/**
Expand Down Expand Up @@ -80,9 +81,9 @@ public static function getCitizenSearchResourceLoaderConfig(
'wgCitizenSearchGateway' => $config->get( 'CitizenSearchGateway' ),
'wgCitizenSearchDescriptionSource' => $config->get( 'CitizenSearchDescriptionSource' ),
'wgCitizenMaxSearchResults' => $config->get( 'CitizenMaxSearchResults' ),
'wgScript' => $config->get( 'Script' ),
'wgScriptPath' => $config->get( 'ScriptPath' ),
'wgSearchSuggestCacheExpiry' => $config->get( 'SearchSuggestCacheExpiry' ),
'wgScript' => $config->get( MainConfigNames::Script ),
'wgScriptPath' => $config->get( MainConfigNames::ScriptPath ),
'wgSearchSuggestCacheExpiry' => $config->get( MainConfigNames::SearchSuggestCacheExpiry ),
'isMediaSearchExtensionEnabled' => ExtensionRegistry::getInstance()->isLoaded( 'MediaSearch' ),
];
}
Expand Down
3 changes: 2 additions & 1 deletion includes/Partials/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace MediaWiki\Skins\Citizen\Partials;

use Exception;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;

final class Metadata extends Partial {
Expand All @@ -50,7 +51,7 @@ public function addMetadata() {
private function addManifest() {
if (
$this->getConfigValue( 'CitizenEnableManifest' ) !== true ||
$this->getConfigValue( 'GroupPermissions' )['*']['read'] !== true
$this->getConfigValue( MainConfigNames::GroupPermissions )['*']['read'] !== true
) {
return;
}
Expand Down

0 comments on commit 9110ef1

Please sign in to comment.