MediaWiki  1.33.0
MediaWikiGadgetsDefinitionRepo Class Reference

Gadgets repo powered by MediaWiki:Gadgets-definition. More...

Inheritance diagram for MediaWikiGadgetsDefinitionRepo:
Collaboration diagram for MediaWikiGadgetsDefinitionRepo:

Public Member Functions

 fetchStructuredList ( $forceNewText=null)
 Fetch list of gadgets and returns it as associative array of sections with gadgets e.g. More...
 
 getGadget ( $id)
 
 getGadgetIds ()
 Get the ids of the gadgets provided by this repository. More...
 
 handlePageUpdate (LinkTarget $target)
 Given that the provided page was updated, invalidate caches if necessary. More...
 
 newFromDefinition ( $definition, $category)
 Creates an instance of this class from definition in MediaWiki:Gadgets-definition. More...
 
- Public Member Functions inherited from GadgetRepo
 getStructuredList ()
 Get a list of gadgets sorted by category. More...
 
 handlePageCreation (LinkTarget $target)
 Given that the provided page was created, invalidate caches if necessary. More...
 
 handlePageDeletion (LinkTarget $target)
 Given that the provided page was updated, invalidate caches if necessary. More...
 

Public Attributes

const CACHE_VERSION = 2
 

Protected Member Functions

 loadGadgets ()
 Loads list of gadgets and returns it as associative array of sections with gadgets e.g. More...
 

Private Member Functions

 getDefinitionCacheKey ()
 
 listFromDefinition ( $definition)
 Generates a structured list of Gadget objects from a definition. More...
 
 purgeDefinitionCache ()
 Purge the definitions cache, for example if MediaWiki:Gadgets-definition was edited. More...
 

Private Attributes

 $definitionCache
 

Additional Inherited Members

- Static Public Member Functions inherited from GadgetRepo
static setSingleton ( $repo=null)
 Should only be used by unit tests. More...
 
static singleton ()
 Get the configured default GadgetRepo. More...
 

Detailed Description

Gadgets repo powered by MediaWiki:Gadgets-definition.

Definition at line 10 of file MediaWikiGadgetsDefinitionRepo.php.

Member Function Documentation

◆ fetchStructuredList()

MediaWikiGadgetsDefinitionRepo::fetchStructuredList (   $forceNewText = null)

Fetch list of gadgets and returns it as associative array of sections with gadgets e.g.

[ $name => $gadget1, etc. ]

Parameters
string | null$forceNewTextInjected text of MediaWiki:gadgets-definition [optional]
Returns
array|bool

Definition at line 135 of file MediaWikiGadgetsDefinitionRepo.php.

References $rev, $source, $title, captcha-old\count, listFromDefinition(), Title\makeTitle(), Revision\newFromTitle(), NS_MEDIAWIKI, and wfDebug().

◆ getDefinitionCacheKey()

MediaWikiGadgetsDefinitionRepo::getDefinitionCacheKey ( )
private

Definition at line 54 of file MediaWikiGadgetsDefinitionRepo.php.

References $cache, and Gadget\GADGET_CLASS_VERSION.

Referenced by loadGadgets(), and purgeDefinitionCache().

◆ getGadget()

MediaWikiGadgetsDefinitionRepo::getGadget (   $id)
Parameters
string$id
Returns
Gadget
Exceptions
InvalidArgumentException

Reimplemented from GadgetRepo.

Definition at line 21 of file MediaWikiGadgetsDefinitionRepo.php.

References loadGadgets().

◆ getGadgetIds()

MediaWikiGadgetsDefinitionRepo::getGadgetIds ( )

Get the ids of the gadgets provided by this repository.

It's possible this could be out of sync with what getGadget() will return due to caching

Returns
string[]

Reimplemented from GadgetRepo.

Definition at line 30 of file MediaWikiGadgetsDefinitionRepo.php.

References loadGadgets().

◆ handlePageUpdate()

MediaWikiGadgetsDefinitionRepo::handlePageUpdate ( LinkTarget  $target)

Given that the provided page was updated, invalidate caches if necessary.

Parameters
LinkTarget$target
Returns
void

Reimplemented from GadgetRepo.

Definition at line 39 of file MediaWikiGadgetsDefinitionRepo.php.

References MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\getText(), NS_MEDIAWIKI, and purgeDefinitionCache().

◆ listFromDefinition()

MediaWikiGadgetsDefinitionRepo::listFromDefinition (   $definition)
private

Generates a structured list of Gadget objects from a definition.

Parameters
string$definition
Returns
Gadget[] List of Gadget objects indexed by the gadget's name.

Definition at line 166 of file MediaWikiGadgetsDefinitionRepo.php.

References $line, $lines, $section, as, and newFromDefinition().

Referenced by fetchStructuredList().

◆ loadGadgets()

MediaWikiGadgetsDefinitionRepo::loadGadgets ( )
protected

Loads list of gadgets and returns it as associative array of sections with gadgets e.g.

[ 'sectionnname1' => [ $gadget1, $gadget2 ], 'sectionnname2' => [ $gadget3 ] ];

Returns
array|bool Gadget array or false on failure

Definition at line 70 of file MediaWikiGadgetsDefinitionRepo.php.

References $definitionCache, $value, Gadget\CACHE_TTL, DB_REPLICA, getDefinitionCacheKey(), ObjectCache\getLocalServerInstance(), WANObjectCache\HOLDOFF_TTL, WANObjectCache\TTL_UNCACHEABLE, use, and wfGetDB().

Referenced by getGadget(), and getGadgetIds().

◆ newFromDefinition()

MediaWikiGadgetsDefinitionRepo::newFromDefinition (   $definition,
  $category 
)

Creates an instance of this class from definition in MediaWiki:Gadgets-definition.

Parameters
string$definitionGadget definition
string$category
Returns
Gadget|bool Instance of Gadget class or false if $definition is invalid

Definition at line 194 of file MediaWikiGadgetsDefinitionRepo.php.

References $options, $params, as, and Gadget\isValidGadgetID().

Referenced by listFromDefinition().

◆ purgeDefinitionCache()

MediaWikiGadgetsDefinitionRepo::purgeDefinitionCache ( )
private

Purge the definitions cache, for example if MediaWiki:Gadgets-definition was edited.

Definition at line 49 of file MediaWikiGadgetsDefinitionRepo.php.

References $cache, and getDefinitionCacheKey().

Referenced by handlePageUpdate().

Member Data Documentation

◆ $definitionCache

MediaWikiGadgetsDefinitionRepo::$definitionCache
private

Definition at line 13 of file MediaWikiGadgetsDefinitionRepo.php.

Referenced by loadGadgets().

◆ CACHE_VERSION

const MediaWikiGadgetsDefinitionRepo::CACHE_VERSION = 2

Definition at line 11 of file MediaWikiGadgetsDefinitionRepo.php.


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