MediaWiki REL1_34
CommentStoreComment.php
Go to the documentation of this file.
1<?php
23
30
32 public $id;
33
35 public $text;
36
38 public $message;
39
41 public $data;
42
50 public function __construct( $id, $text, Message $message = null, array $data = null ) {
51 $this->id = $id;
52 $this->text = $text;
53 $this->message = $message ?: new RawMessage( '$1', [ Message::plaintextParam( $text ) ] );
54 $this->data = $data;
55 }
56
66 public static function newUnsavedComment( $comment, array $data = null ) {
67 if ( $comment instanceof CommentStoreComment ) {
68 return $comment;
69 }
70
71 if ( $data !== null ) {
72 foreach ( $data as $k => $v ) {
73 if ( substr( $k, 0, 1 ) === '_' ) {
74 throw new InvalidArgumentException( 'Keys in $data beginning with "_" are reserved' );
75 }
76 }
77 }
78
79 if ( $comment instanceof Message ) {
80 $message = clone $comment;
81 // Avoid $wgForceUIMsgAsContentMsg
82 $text = $message->inLanguage( MediaWikiServices::getInstance()->getContentLanguage() )
83 ->setInterfaceMessageFlag( true )
84 ->text();
85 return new CommentStoreComment( null, $text, $message, $data );
86 } else {
87 return new CommentStoreComment( null, $comment, null, $data );
88 }
89 }
90}
CommentStoreComment represents a comment stored by CommentStore.
string $text
Text version of the comment.
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
int null $id
Comment ID, if any.
__construct( $id, $text, Message $message=null, array $data=null)
Message $message
Message version of the comment.
array null $data
Structured data of the comment.
MediaWikiServices is the service locator for the application scope of MediaWiki.
The Message class provides methods which fulfil two basic services:
Definition Message.php:162
static plaintextParam( $plaintext)
Definition Message.php:1104
inLanguage( $lang)
Request the message in any language that is supported.
Definition Message.php:732
Variant of the Message class.