MediaWiki REL1_39
CommentBatch.php
Go to the documentation of this file.
1<?php
2
4
6use Traversable;
7
15 private $formatter;
17 private $comments;
19 private $useBlock;
21 private $useParentheses;
23 private $selfLinkTarget;
25 private $samePage;
27 private $wikiId;
29 private $enableSectionLinks;
30
36 public function __construct( CommentFormatter $formatter ) {
37 $this->formatter = $formatter;
38 }
39
50 public function comments( $comments ) {
51 $this->comments = $comments;
52 return $this;
53 }
54
65 public function strings( array $strings ) {
66 $this->comments = new StringCommentIterator( $strings );
67 return $this;
68 }
69
80 public function useBlock( $useBlock = true ) {
81 $this->useBlock = $useBlock;
82 return $this;
83 }
84
96 public function useParentheses( $useParentheses = true ) {
97 $this->useParentheses = $useParentheses;
98 return $this;
99 }
100
109 public function selfLinkTarget( LinkTarget $selfLinkTarget ) {
110 $this->selfLinkTarget = $selfLinkTarget;
111 return $this;
112 }
113
126 public function enableSectionLinks( $enable ) {
127 $this->enableSectionLinks = $enable;
128 return $this;
129 }
130
139 public function disableSectionLinks() {
140 $this->enableSectionLinks = false;
141 return $this;
142 }
143
156 public function samePage( $samePage = true ) {
157 $this->samePage = $samePage;
158 return $this;
159 }
160
172 public function wikiId( $wikiId ) {
173 $this->wikiId = $wikiId;
174 return $this;
175 }
176
182 public function execute() {
183 return $this->formatter->formatItemsInternal(
184 $this->comments,
185 $this->selfLinkTarget,
186 $this->samePage,
187 $this->wikiId,
188 $this->enableSectionLinks,
189 $this->useBlock,
190 $this->useParentheses
191 );
192 }
193
194}
This class provides a fluent interface for formatting a batch of comments.
enableSectionLinks( $enable)
Set the option to enable/disable section links formatted as C-style comments, as used in revision com...
useParentheses( $useParentheses=true)
Wrap each comment with parentheses.
execute()
Format the comments and produce an array of HTML fragments.
wikiId( $wikiId)
ID of the wiki to link to (if not the local wiki), as used by WikiMap.
selfLinkTarget(LinkTarget $selfLinkTarget)
Set the title to be used for self links in the comments.
comments( $comments)
Set the comments to be formatted.
__construct(CommentFormatter $formatter)
useBlock( $useBlock=true)
Wrap each comment in standard punctuation and formatting if it's non-empty.
strings(array $strings)
Specify the comments to be formatted as an array of strings.
disableSectionLinks()
Disable section links formatted as C-style comments, as used in revision comments to indicate the sec...
samePage( $samePage=true)
Set the same-page option.
This is the main service interface for converting single-line comments from various DB comment fields...
An adaptor which converts an array of strings to an iterator of CommentItem objects.