MediaWiki master
MediaWiki\Category\TrackingCategories Class Reference

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

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, getting the title from a system message.
 
 getTrackingCategories ()
 Read the global and extract title objects from the corresponding messages.
 
 resolveTrackingCategory (string $msg, ?PageReference $contextPage)
 Resolve a tracking category.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

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

Since
1.29

Definition at line 42 of file TrackingCategories.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 100 of file TrackingCategories.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and ExtensionRegistry\getInstance().

Member Function Documentation

◆ addTrackingCategory()

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

Add a tracking category to a ParserOutput, getting the title from a system message.

Any message used with this function should be registered so it will show up on [[Special:TrackingCategories]]. Core messages should be added to TrackingCategories::CORE_TRACKING_CATEGORIES, and extensions should add to "TrackingCategories" in their extension.json.

Parameters
ParserOutput$parserOutputThe target ParserOutput which will store the new category
string$msgMessage key
?PageReference$contextPageContext page title
Returns
bool Whether the addition was successful
Since
1.38
See also
Parser::addTrackingCategory

Definition at line 257 of file TrackingCategories.php.

◆ getTrackingCategories()

MediaWiki\Category\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' => LinkTarget, 'cats' => LinkTarget[] ]

Definition at line 126 of file TrackingCategories.php.

References MediaWiki\MainConfigNames\EnableMagicLinks, NS_CATEGORY, NS_MEDIAWIKI, MediaWiki\MainConfigNames\TrackingCategories, and wfMessage().

◆ resolveTrackingCategory()

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

Resolve a tracking category.

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

Definition at line 209 of file TrackingCategories.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Category\TrackingCategories::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const EnableMagicLinks
Name constant for the EnableMagicLinks setting, for use with Config::get()
const TrackingCategories
Name constant for the TrackingCategories setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 47 of file TrackingCategories.php.


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