MediaWiki REL1_37
MediaWiki\Actions\ActionFactory Class Reference
Collaboration diagram for MediaWiki\Actions\ActionFactory:

Public Member Functions

 __construct (array $actionsConfig, LoggerInterface $logger, ObjectFactory $objectFactory, HookContainer $hookContainer)
 
 actionExists (string $actionName)
 
 getAction (string $actionName, Article $article, IContextSource $context)
 Get an appropriate Action subclass for the given action, taking into account Article-specific overrides.
 
 getActionName (IContextSource $context)
 Get the name of the action that will be executed, not necessarily the one passed through the "action" request parameter.
 

Protected Member Functions

 getArticle (IContextSource $context)
 Protected to allow overriding with a partial mock in unit tests.
 

Private Member Functions

 getActionSpec (string $actionName)
 

Private Attributes

array $actionsConfig
 Configured actions (eg those added by extensions to $wgActions) that overrides CORE_ACTIONS.
 
HookRunner $hookRunner
 
LoggerInterface $logger
 
ObjectFactory $objectFactory
 
const CORE_ACTIONS
 Core default action specifications.
 

Detailed Description

Since
1.37
Author
DannyS712

Definition at line 45 of file ActionFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Actions\ActionFactory::__construct ( array  $actionsConfig,
LoggerInterface  $logger,
ObjectFactory  $objectFactory,
HookContainer  $hookContainer 
)
Parameters
array$actionsConfigConfigured actions (eg those added by extensions to $wgActions)
LoggerInterface$logger
ObjectFactory$objectFactory
HookContainer$hookContainer

Definition at line 201 of file ActionFactory.php.

References MediaWiki\Actions\ActionFactory\$actionsConfig, MediaWiki\Actions\ActionFactory\$logger, and MediaWiki\Actions\ActionFactory\$objectFactory.

Member Function Documentation

◆ actionExists()

MediaWiki\Actions\ActionFactory::actionExists ( string  $actionName)
Parameters
string$actionName
Returns
bool

Definition at line 368 of file ActionFactory.php.

◆ getAction()

MediaWiki\Actions\ActionFactory::getAction ( string  $actionName,
Article  $article,
IContextSource  $context 
)

Get an appropriate Action subclass for the given action, taking into account Article-specific overrides.

Parameters
string$actionName
Article$article
IContextSource$context
Returns
Action|bool|null False if the action is disabled, null if not recognized

Definition at line 241 of file ActionFactory.php.

References Article\getActionOverrides(), and MediaWiki\Actions\ActionFactory\getActionSpec().

◆ getActionName()

MediaWiki\Actions\ActionFactory::getActionName ( IContextSource  $context)

Get the name of the action that will be executed, not necessarily the one passed through the "action" request parameter.

Actions disabled in $wgActions will be replaced by "nosuchaction".

Parameters
IContextSource$context
Returns
string Action name

Definition at line 309 of file ActionFactory.php.

◆ getActionSpec()

MediaWiki\Actions\ActionFactory::getActionSpec ( string  $actionName)
private
Parameters
string$actionNameshould already be in all lowercase
Returns
string|callable|bool|Action|array|null The spec for the action, in any valid form, based on $this->actionsConfig, or if not included there, CORE_ACTIONS, or null if the action does not exist.

Definition at line 219 of file ActionFactory.php.

Referenced by MediaWiki\Actions\ActionFactory\getAction().

◆ getArticle()

MediaWiki\Actions\ActionFactory::getArticle ( IContextSource  $context)
protected

Protected to allow overriding with a partial mock in unit tests.

Parameters
IContextSource$context
Returns
Article

Definition at line 384 of file ActionFactory.php.

Member Data Documentation

◆ $actionsConfig

array MediaWiki\Actions\ActionFactory::$actionsConfig
private

Configured actions (eg those added by extensions to $wgActions) that overrides CORE_ACTIONS.

Definition at line 51 of file ActionFactory.php.

Referenced by MediaWiki\Actions\ActionFactory\__construct().

◆ $hookRunner

HookRunner MediaWiki\Actions\ActionFactory::$hookRunner
private

Definition at line 60 of file ActionFactory.php.

◆ $logger

LoggerInterface MediaWiki\Actions\ActionFactory::$logger
private

Definition at line 54 of file ActionFactory.php.

Referenced by MediaWiki\Actions\ActionFactory\__construct().

◆ $objectFactory

ObjectFactory MediaWiki\Actions\ActionFactory::$objectFactory
private

Definition at line 57 of file ActionFactory.php.

Referenced by MediaWiki\Actions\ActionFactory\__construct().

◆ CORE_ACTIONS

const MediaWiki\Actions\ActionFactory::CORE_ACTIONS
private

Core default action specifications.

'foo' => 'ClassName'    Load the specified class which subclasses Action
'foo' => a callable     Load the class returned by the callable
'foo' => true           Load the class FooAction which subclasses Action
'foo' => false          The action is disabled; show an error message
'foo' => an object      Use the specified object, which subclasses Action, useful for tests.
'foo' => an array       Slowly being used to replace the first three. The array
                          is treated as a specification for an ObjectFactory.

Definition at line 73 of file ActionFactory.php.


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