MediaWiki
master
CommentStoreComment.php
Go to the documentation of this file.
1
<?php
20
use
MediaWiki\MediaWikiServices
;
21
30
class
CommentStoreComment
{
31
33
public
$id
;
34
36
public
$text
;
37
39
public
$message
;
40
42
public
$data
;
43
51
public
function
__construct
(
$id
,
$text
,
Message
$message
=
null
, array
$data
=
null
) {
52
$this->
id
=
$id
;
53
$this->text =
$text
;
54
$this->message =
$message
?:
new
RawMessage
(
'$1'
, [
Message::plaintextParam
(
$text
) ] );
55
$this->data =
$data
;
56
}
57
67
public
static
function
newUnsavedComment
( $comment, array
$data
=
null
) {
68
if
( $comment instanceof
CommentStoreComment
) {
69
return
$comment;
70
}
71
72
if
(
$data
!==
null
) {
73
foreach
(
$data
as $k => $v ) {
74
if
( substr( $k, 0, 1 ) ===
'_'
) {
75
throw
new
InvalidArgumentException(
'Keys in $data beginning with "_" are reserved'
);
76
}
77
}
78
}
79
80
if
( $comment instanceof
Message
) {
81
$message
= clone $comment;
82
// Avoid $wgForceUIMsgAsContentMsg
83
$text
=
$message
->
inLanguage
( MediaWikiServices::getInstance()->getContentLanguage() )
84
->setInterfaceMessageFlag(
true
)
85
->text();
86
return
new
CommentStoreComment
(
null
,
$text
,
$message
,
$data
);
87
}
else
{
88
return
new
CommentStoreComment
(
null
, $comment,
null
,
$data
);
89
}
90
}
91
}
CommentStoreComment\newUnsavedComment
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
Definition:
CommentStoreComment.php:67
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition:
MediaWikiServices.php:172
CommentStoreComment\$text
string $text
Text version of the comment.
Definition:
CommentStoreComment.php:36
CommentStoreComment\$data
array null $data
Structured data of the comment.
Definition:
CommentStoreComment.php:42
Message\plaintextParam
static plaintextParam( $plaintext)
Definition:
Message.php:1104
CommentStoreComment\$message
Message $message
Message version of the comment.
Definition:
CommentStoreComment.php:39
CommentStoreComment\__construct
__construct( $id, $text, Message $message=null, array $data=null)
Definition:
CommentStoreComment.php:51
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition:
Message.php:161
CommentStoreComment\$id
int null $id
Comment ID, if any.
Definition:
CommentStoreComment.php:33
RawMessage
Variant of the Message class.
Definition:
RawMessage.php:35
Message\inLanguage
inLanguage( $lang)
Request the message in any language that is supported.
Definition:
Message.php:730
CommentStoreComment
Value object for a comment stored by CommentStore.
Definition:
CommentStoreComment.php:30
includes
CommentStoreComment.php
Generated on Thu Feb 25 2021 19:08:30 for MediaWiki by
1.8.19