MediaWiki  master
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. More...
 
 getActionName (IContextSource $context)
 Get the name of the action that will be executed, not necessarily the one passed through the "action" request parameter. More...
 

Protected Member Functions

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

Private Member Functions

 getActionSpec (string $actionName)
 

Private Attributes

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

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 208 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)
Deprecated:
since 1.38
Parameters
string$actionName
Returns
bool

Definition at line 384 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 248 of file ActionFactory.php.

References MediaWiki\$context, 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 324 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 226 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 401 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: