mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 19:12:16 +00:00
c6c7dd2fb0
Why: - We want to allow extensions to register interactive menu items in the overflow menu. What: - Create a PHP hook to allow extensions to provide menu items for rendering in the overflow menu - The hook allows for registering resource loader modules required by the menu item - The hook passes in some contextual information, like the thread item data, context source object, and if the page is editable - Create a JS hook that fires when a user selects one of the menu items - Example implementation: Ie9afbedb4f24cbd75eb48bb21dc9f6d8d732d853 Misc: - Remove b/c code that existed to handle a transitional period where JSON encoded overflow menu data did not necessarily exist in the parser cache - Rename code instances of ellipsis button / data / menu to refer to "overflow menu" - Some renames will have to wait until parser cache is updated; these are noted with TODOs Bug: T342251 Change-Id: I5f2a51791f8ba7619d1399a4b93111e9bb44e172
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Hooks;
|
|
|
|
use Config;
|
|
use IContextSource;
|
|
use MediaWiki\HookContainer\HookContainer;
|
|
use MessageLocalizer;
|
|
|
|
/**
|
|
* This is a hook runner class, see docs/Hooks.md in core.
|
|
* @internal
|
|
*/
|
|
class HookRunner implements
|
|
DiscussionToolsTermsOfUseMessagesHook,
|
|
DiscussionToolsAddOverflowMenuItemsHook
|
|
{
|
|
private HookContainer $hookContainer;
|
|
|
|
public function __construct( HookContainer $hookContainer ) {
|
|
$this->hookContainer = $hookContainer;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function onDiscussionToolsTermsOfUseMessages( array &$messages, MessageLocalizer $context, Config $config ) {
|
|
return $this->hookContainer->run(
|
|
'DiscussionToolsTermsOfUseMessages',
|
|
[ &$messages, $context, $config ]
|
|
);
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function onDiscussionToolsAddOverflowMenuItems(
|
|
array &$overflowMenuItems,
|
|
array &$resourceLoaderModules,
|
|
bool $isSectionEditable,
|
|
array $threadItemData,
|
|
IContextSource $contextSource
|
|
) {
|
|
return $this->hookContainer->run(
|
|
'DiscussionToolsAddOverflowMenuItems',
|
|
[
|
|
&$overflowMenuItems,
|
|
&$resourceLoaderModules,
|
|
$isSectionEditable,
|
|
$threadItemData,
|
|
$contextSource,
|
|
]
|
|
);
|
|
}
|
|
}
|