Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4103762
HeadingItemTrait.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HeadingItemTrait.php
View Options
<?php
namespace
MediaWiki\Extension\DiscussionTools\ThreadItem
;
trait
HeadingItemTrait
{
// phpcs:disable Squiz.WhiteSpace, MediaWiki.Commenting
// Required ThreadItem methods (listed for Phan)
abstract
public
function
getName
():
string
;
// Required HeadingItem methods (listed for Phan)
abstract
public
function
getHeadingLevel
():
int
;
abstract
public
function
isPlaceholderHeading
():
bool
;
// phpcs:enable
/**
* @inheritDoc
* @suppress PhanTraitParentReference
*/
public
function
jsonSerialize
(
bool
$deep
=
false
,
?
callable
$callback
=
null
):
array
{
return
array_merge
(
[
'headingLevel'
=>
$this
->
isPlaceholderHeading
()
?
null
:
$this
->
getHeadingLevel
(),
// Used for topic subscriptions. Not added to CommentItem's yet as there is
// no use case for it.
'name'
=>
$this
->
getName
(),
],
parent
::
jsonSerialize
(
$deep
,
$callback
)
);
}
/**
* Check whether this heading can be used for topic subscriptions.
*/
public
function
isSubscribable
():
bool
{
return
(
// Placeholder headings have nothing to attach the button to.
!
$this
->
isPlaceholderHeading
()
&&
// We only allow subscribing to level 2 headings, because the user interface for sub-headings
// would be difficult to present.
$this
->
getHeadingLevel
()
===
2
&&
// Check if the name corresponds to a section that contain no comments (only sub-sections).
// They can't be distinguished from each other, so disallow subscribing.
$this
->
getName
()
!==
'h-'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 18:08 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8b/9b/e50f92728bdac56a5b428279dacb
Default Alt Text
HeadingItemTrait.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment