mediawiki-extensions-Discus.../includes/Hooks/DiscussionToolsHooks.php
Ed Sanders f8b76afef3 [BREAKING CHANGE] Remove isSectionEditable from overflow hook
Instead make isUneditableSection an optional property of
ContentHeadingItem.

Change-Id: Icfddf28aa789b5014ac183ff9f9699f38d78c121
2023-10-18 12:56:46 +01:00

46 lines
1 KiB
PHP

<?php
/**
* DiscussionTools hooks for listening to our own hooks
*
* @file
* @ingroup Extensions
* @license MIT
*/
namespace MediaWiki\Extension\DiscussionTools\Hooks;
use IContextSource;
use MediaWiki\Extension\DiscussionTools\OverflowMenuItem;
class DiscussionToolsHooks implements
DiscussionToolsAddOverflowMenuItemsHook
{
/**
* @param OverflowMenuItem[] &$overflowMenuItems
* @param string[] &$resourceLoaderModules
* @param array $threadItemData
* @param IContextSource $contextSource
* @return bool|void
*/
public function onDiscussionToolsAddOverflowMenuItems(
array &$overflowMenuItems,
array &$resourceLoaderModules,
array $threadItemData,
IContextSource $contextSource
) {
if (
( $threadItemData['type'] ?? null ) === 'heading' &&
!( $threadItemData['uneditableSection'] ?? false ) &&
$contextSource->getSkin()->getSkinName() === 'minerva'
) {
$overflowMenuItems[] = new OverflowMenuItem(
'edit',
'edit',
$contextSource->msg( 'skin-view-edit' ),
2
);
}
}
}