MediaWiki  master
TrackingCategories Class Reference

This class performs some operations related to tracking categories, such as creating a list of all such categories. More...

Collaboration diagram for TrackingCategories:

Public Member Functions

 __construct (ServiceOptions $options, NamespaceInfo $namespaceInfo, TitleParser $titleParser, LoggerInterface $logger)
 
 addTrackingCategory (ParserOutput $parserOutput, string $msg, ?PageReference $contextPage)
 Add a tracking category to a ParserOutput. More...
 
 getTrackingCategories ()
 Read the global and extract title objects from the corresponding messages. More...
 
 resolveTrackingCategory (string $msg, ?PageReference $contextPage)
 Resolve a tracking category. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Attributes

ExtensionRegistry $extensionRegistry
 
LoggerInterface $logger
 
NamespaceInfo $namespaceInfo
 
ServiceOptions $options
 
TitleParser $titleParser
 

Detailed Description

This class performs some operations related to tracking categories, such as creating a list of all such categories.

Since
1.29

Definition at line 32 of file TrackingCategories.php.

Constructor & Destructor Documentation

◆ __construct()

TrackingCategories::__construct ( ServiceOptions  $options,
NamespaceInfo  $namespaceInfo,
TitleParser  $titleParser,
LoggerInterface  $logger 
)
Parameters
ServiceOptions$options
NamespaceInfo$namespaceInfo
TitleParser$titleParser
LoggerInterface$logger

Definition at line 87 of file TrackingCategories.php.

References $logger, $namespaceInfo, $options, $titleParser, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and ExtensionRegistry\getInstance().

Member Function Documentation

◆ addTrackingCategory()

TrackingCategories::addTrackingCategory ( ParserOutput  $parserOutput,
string  $msg,
?PageReference  $contextPage 
)

Add a tracking category to a ParserOutput.

Parameters
ParserOutput$parserOutput
string$msgMessage key
?PageReference$contextPage Context page title
Returns
bool Whether the addition was successful
Since
1.38

Definition at line 235 of file TrackingCategories.php.

References ParserOutput\addCategory(), ParserOutput\getPageProperty(), and resolveTrackingCategory().

◆ getTrackingCategories()

TrackingCategories::getTrackingCategories ( )

Read the global and extract title objects from the corresponding messages.

TODO consider renaming this method, since this class is retrieved from MediaWikiServices, resulting in calls like: MediaWikiServices::getInstance()->getTrackingCategories()->getTrackingCategories()

Returns
array[] [ 'msg' => Title, 'cats' => Title[] ]

Definition at line 113 of file TrackingCategories.php.

References Title\newFromTitleValue(), NS_CATEGORY, NS_MEDIAWIKI, and wfMessage().

◆ resolveTrackingCategory()

TrackingCategories::resolveTrackingCategory ( string  $msg,
?PageReference  $contextPage 
)

Resolve a tracking category.

Parameters
string$msgMessage key
?PageReference$contextPage Context page title
Returns
?LinkTarget the proper category page, or null if the tracking category is disabled or unsafe
Since
1.38

Definition at line 196 of file TrackingCategories.php.

References Page\PageReference\getNamespace(), NS_CATEGORY, NS_SPECIAL, and wfMessage().

Referenced by addTrackingCategory().

Member Data Documentation

◆ $extensionRegistry

ExtensionRegistry TrackingCategories::$extensionRegistry
private

Definition at line 52 of file TrackingCategories.php.

◆ $logger

LoggerInterface TrackingCategories::$logger
private

Definition at line 55 of file TrackingCategories.php.

Referenced by __construct().

◆ $namespaceInfo

NamespaceInfo TrackingCategories::$namespaceInfo
private

Definition at line 46 of file TrackingCategories.php.

Referenced by __construct().

◆ $options

ServiceOptions TrackingCategories::$options
private

Definition at line 43 of file TrackingCategories.php.

Referenced by __construct().

◆ $titleParser

TitleParser TrackingCategories::$titleParser
private

Definition at line 49 of file TrackingCategories.php.

Referenced by __construct().

◆ CONSTRUCTOR_OPTIONS

const TrackingCategories::CONSTRUCTOR_OPTIONS
Initial value:
= [
'TrackingCategories',
'EnableMagicLinks',
]
Access: internal
For use by ServiceWiring

Definition at line 37 of file TrackingCategories.php.


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