MediaWiki  master
MediaWiki\Permissions\GrantsLocalization Class Reference

This separate service is needed because the ::getGrantsLink method requires a LinkRenderer and if we tried to inject a LinkRenderer into the GrantsInfo service, it would result in recursive service instantiation for sessions using the BotPasswordSessionProvider, as a result of injecting the LinkRenderer when trying to use a GrantsInfo method that doesn't even need it. More...

Collaboration diagram for MediaWiki\Permissions\GrantsLocalization:

Public Member Functions

 __construct (GrantsInfo $grantsInfo, LinkRenderer $linkRenderer, LanguageFactory $languageFactory, Language $contentLanguage)
 
 getGrantDescription (string $grant, $lang=null)
 Fetch the description of the grant. More...
 
 getGrantDescriptions (array $grants, $lang=null)
 Fetch the descriptions for the grants. More...
 
 getGrantsLink (string $grant, $lang=null)
 Generate a link to Special:ListGrants for a particular grant name. More...
 
 getGrantsWikiText ( $grantsFilter, $lang=null)
 Generate wikitext to display a list of grants. More...
 

Private Attributes

Language $contentLanguage
 
GrantsInfo $grantsInfo
 
LanguageFactory $languageFactory
 
LinkRenderer $linkRenderer
 

Detailed Description

This separate service is needed because the ::getGrantsLink method requires a LinkRenderer and if we tried to inject a LinkRenderer into the GrantsInfo service, it would result in recursive service instantiation for sessions using the BotPasswordSessionProvider, as a result of injecting the LinkRenderer when trying to use a GrantsInfo method that doesn't even need it.

Since
1.38

Definition at line 37 of file GrantsLocalization.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Permissions\GrantsLocalization::__construct ( GrantsInfo  $grantsInfo,
LinkRenderer  $linkRenderer,
LanguageFactory  $languageFactory,
Language  $contentLanguage 
)

Member Function Documentation

◆ getGrantDescription()

MediaWiki\Permissions\GrantsLocalization::getGrantDescription ( string  $grant,
  $lang = null 
)

Fetch the description of the grant.

Parameters
string$grant
Language | string | null$lang
Returns
string Grant description

Definition at line 74 of file GrantsLocalization.php.

References $lang, and wfMessage().

Referenced by MediaWiki\Permissions\GrantsLocalization\getGrantDescriptions(), and MediaWiki\Permissions\GrantsLocalization\getGrantsLink().

◆ getGrantDescriptions()

MediaWiki\Permissions\GrantsLocalization::getGrantDescriptions ( array  $grants,
  $lang = null 
)

Fetch the descriptions for the grants.

Parameters
string[]$grants
Language | string | null$lang
Returns
string[] Corresponding grant descriptions

Definition at line 107 of file GrantsLocalization.php.

References $lang, and MediaWiki\Permissions\GrantsLocalization\getGrantDescription().

Referenced by MediaWiki\Permissions\GrantsLocalization\getGrantsWikiText().

◆ getGrantsLink()

MediaWiki\Permissions\GrantsLocalization::getGrantsLink ( string  $grant,
  $lang = null 
)

Generate a link to Special:ListGrants for a particular grant name.

This should be used to link end users to a full description of what rights they are giving when they authorize a grant.

Parameters
string$grantthe grant name
Language | string | null$lang
Returns
string (proto-relative) HTML link

Definition at line 126 of file GrantsLocalization.php.

References $lang, MediaWiki\Permissions\GrantsLocalization\getGrantDescription(), and SpecialPage\getTitleFor().

◆ getGrantsWikiText()

MediaWiki\Permissions\GrantsLocalization::getGrantsWikiText (   $grantsFilter,
  $lang = null 
)

Generate wikitext to display a list of grants.

Parameters
string[] | null$grantsFilterIf non-null, only display these grants.
Language | string | null$lang
Returns
string Wikitext

Definition at line 139 of file GrantsLocalization.php.

References MediaWiki\Permissions\GrantsLocalization\$contentLanguage, $lang, $s, MediaWiki\Permissions\GrantsLocalization\getGrantDescriptions(), and wfMessage().

Member Data Documentation

◆ $contentLanguage

Language MediaWiki\Permissions\GrantsLocalization::$contentLanguage
private

◆ $grantsInfo

GrantsInfo MediaWiki\Permissions\GrantsLocalization::$grantsInfo
private

◆ $languageFactory

LanguageFactory MediaWiki\Permissions\GrantsLocalization::$languageFactory
private

◆ $linkRenderer

LinkRenderer MediaWiki\Permissions\GrantsLocalization::$linkRenderer
private

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