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...

Public Member Functions

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

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 39 of file GrantsLocalization.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 58 of file GrantsLocalization.php.

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 76 of file GrantsLocalization.php.

◆ 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, keyed by grant name

Definition at line 109 of file GrantsLocalization.php.

◆ getGrantDescriptionsWithClasses()

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

Fetch the descriptions for the grants, like getGrantDescriptions, but with HTML classes for styling.

The HTML is wikitext-compatible.

Parameters
string[]$grants
Language | string | null$lang
Returns
string[] Grant description HTML for each grant, in the same order

Definition at line 125 of file GrantsLocalization.php.

◆ getGrantsLink()

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

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

This can 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 158 of file GrantsLocalization.php.

◆ getGrantsWikiText()

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

Generate wikitext to display a list of grants.

It will be in the format

  • <grant-group-$group> : <grant-$grant>; <grant-$grant>; ...
  • ... with some HTML classes for styling.
    Parameters
    string[] | null$grantsFilterIf non-null, only display these grants.
    Language | string | null$lang
    Returns
    string Wikitext

Definition at line 177 of file GrantsLocalization.php.


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