Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1430333
ThreadItemTrait.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
ThreadItemTrait.php
View Options
<?php
namespace
MediaWiki\Extension\DiscussionTools\ThreadItem
;
trait
ThreadItemTrait
{
// phpcs:disable Squiz.WhiteSpace, MediaWiki.Commenting
// Required ThreadItem methods (listed for Phan)
abstract
public
function
getId
():
string
;
abstract
public
function
getType
():
string
;
abstract
public
function
getReplies
():
array
;
abstract
public
function
getLevel
():
int
;
// phpcs:enable
/**
* @param bool $deep Whether to include full serialized comments in the replies key
* @param callable|null $callback Function to call on the returned serialized array, which
* will be passed into the serialized replies as well if $deep is used
* @return array JSON-serializable array
*/
public
function
jsonSerialize
(
bool
$deep
=
false
,
?
callable
$callback
=
null
):
array
{
// The output of this method can end up in the HTTP cache (Varnish). Avoid changing it;
// and when doing so, ensure that frontend code can handle both the old and new outputs.
// See ThreadItem.static.newFromJSON in JS.
$array
=
[
'type'
=>
$this
->
getType
(),
'level'
=>
$this
->
getLevel
(),
'id'
=>
$this
->
getId
(),
'replies'
=>
array_map
(
static
function
(
ThreadItem
$comment
)
use
(
$deep
,
$callback
)
{
return
$deep
?
$comment
->
jsonSerialize
(
$deep
,
$callback
)
:
$comment
->
getId
();
},
$this
->
getReplies
()
)
];
if
(
$callback
)
{
$callback
(
$array
,
$this
);
}
return
$array
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 18:38 (3 h, 27 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
db/fc/ced0673cdef4a5a7cc41dbdbafb0
Default Alt Text
ThreadItemTrait.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment