mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 14:06:52 +00:00
Remove the VisualEditorHookRunner service
The HookRunner class is a lightweight class and not designed to be a service, the needed HookContainer should be injected instead and a hook runner created when needed. The overhead from the service wiring is the same as using new objects when needed. This follows practice from core and the documentation in core/docs/Hooks.md in the section "Hook runner classes" Change-Id: Ib42281dfae8a5a260005d82ed3bb7da12e1b645e
This commit is contained in:
parent
1cefa11870
commit
4e94b88f99
|
@ -179,7 +179,7 @@
|
|||
"visualeditoredit": {
|
||||
"class": "MediaWiki\\Extension\\VisualEditor\\ApiVisualEditorEdit",
|
||||
"services": [
|
||||
"VisualEditorHookRunner",
|
||||
"HookContainer",
|
||||
"StatsdDataFactory",
|
||||
"PageEditStash",
|
||||
"SkinFactory",
|
||||
|
|
|
@ -21,6 +21,7 @@ use ExtensionRegistry;
|
|||
use FlaggablePageView;
|
||||
use IBufferingStatsdDataFactory;
|
||||
use IDBAccessObject;
|
||||
use MediaWiki\HookContainer\HookContainer;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
use MediaWiki\Request\DerivativeRequest;
|
||||
|
@ -51,7 +52,7 @@ class ApiVisualEditorEdit extends ApiBase {
|
|||
public function __construct(
|
||||
ApiMain $main,
|
||||
string $name,
|
||||
VisualEditorHookRunner $hookRunner,
|
||||
HookContainer $hookContainer,
|
||||
IBufferingStatsdDataFactory $statsdDataFactory,
|
||||
PageEditStash $pageEditStash,
|
||||
SkinFactory $skinFactory,
|
||||
|
@ -62,7 +63,7 @@ class ApiVisualEditorEdit extends ApiBase {
|
|||
parent::__construct( $main, $name );
|
||||
$this->setLogger( LoggerFactory::getInstance( 'VisualEditor' ) );
|
||||
$this->setStats( $statsdDataFactory );
|
||||
$this->hookRunner = $hookRunner;
|
||||
$this->hookRunner = new VisualEditorHookRunner( $hookContainer );
|
||||
$this->pageEditStash = $pageEditStash;
|
||||
$this->skinFactory = $skinFactory;
|
||||
$this->wikiPageFactory = $wikiPageFactory;
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace MediaWiki\Extension\VisualEditor;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
return [
|
||||
VisualEditorHookRunner::SERVICE_NAME => static function ( MediaWikiServices $services ): VisualEditorHookRunner {
|
||||
return new VisualEditorHookRunner( $services->getHookContainer() );
|
||||
},
|
||||
|
||||
VisualEditorParsoidClientFactory::SERVICE_NAME => static function (
|
||||
MediaWikiServices $services
|
||||
): VisualEditorParsoidClientFactory {
|
||||
|
|
|
@ -23,8 +23,6 @@ class VisualEditorHookRunner implements
|
|||
VisualEditorBeforeEditorHook
|
||||
{
|
||||
|
||||
public const SERVICE_NAME = 'VisualEditorHookRunner';
|
||||
|
||||
/** @var HookContainer */
|
||||
private $hookContainer;
|
||||
|
||||
|
|
Loading…
Reference in a new issue