MediaWiki master
MediaWiki\CommentFormatter\RowCommentFormatter Class Reference

This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment texts directly from database result wrappers. More...

Inherits MediaWiki\CommentFormatter\CommentFormatter.

Collaboration diagram for MediaWiki\CommentFormatter\RowCommentFormatter:

Public Member Functions

 __construct (CommentParserFactory $commentParserFactory, CommentStore $commentStore)
 
 formatRows ( $rows, $commentKey, $namespaceField=null, $titleField=null, $indexField=null, $useBlock=false, $useParentheses=true)
 Format DB rows using a parametric interface.
 
 rows ( $rows)
 Format DB rows using a fluent interface.
 
- Public Member Functions inherited from MediaWiki\CommentFormatter\CommentFormatter
 __construct (CommentParserFactory $parserFactory)
 
 createBatch ()
 Format comments using a fluent interface.
 
 createRevisionBatch ()
 Format a batch of revision comments using a fluent interface.
 
 format (string $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false)
 Format a single comment.
 
 formatBlock (string $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false, $useParentheses=true)
 Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return an empty string.
 
 formatItems ( $items)
 Format an iterator over CommentItem objects.
 
 formatItemsInternal ( $items, $selfLinkTarget=null, $samePage=null, $wikiId=null, $enableSectionLinks=null, $useBlock=null, $useParentheses=null)
 
 formatLinks (string $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false)
 Format links in a comment, ignoring section links in C-style comments.
 
 formatLinksUnsafe (string $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false)
 Format a comment, passing through HTML in the input to the output.
 
 formatRevision (RevisionRecord $revision, Authority $authority, $samePage=false, $isPublic=false, $useParentheses=true)
 Wrap and format the given revision's comment block, if the specified user is allowed to view it.
 
 formatRevisions ( $revisions, Authority $authority, $samePage=false, $isPublic=false, $useParentheses=true, $indexById=false)
 Format multiple revision comments.
 
 formatStrings ( $strings, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false)
 Format comments which are provided as strings and all have the same self-link target and other options.
 
 formatStringsAsBlock ( $strings, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false, $useParentheses=true)
 Given an array of comments as strings which all have the same self link target, format the comments and wrap them in standard punctuation and formatting.
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWiki\CommentFormatter\CommentFormatter
 wrapCommentWithBlock ( $formatted, $useParentheses)
 Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty string.
 
- Protected Attributes inherited from MediaWiki\CommentFormatter\CommentFormatter
CommentParserFactory $parserFactory
 

Detailed Description

This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment texts directly from database result wrappers.

Since
1.38

Definition at line 15 of file RowCommentFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\CommentFormatter\RowCommentFormatter::__construct ( CommentParserFactory $commentParserFactory,
CommentStore $commentStore )
Access: internal
Use MediaWikiServices::getRowCommentFormatter()
Parameters
CommentParserFactory$commentParserFactory
CommentStore$commentStore

Definition at line 25 of file RowCommentFormatter.php.

Member Function Documentation

◆ formatRows()

MediaWiki\CommentFormatter\RowCommentFormatter::formatRows ( $rows,
$commentKey,
$namespaceField = null,
$titleField = null,
$indexField = null,
$useBlock = false,
$useParentheses = true )

Format DB rows using a parametric interface.

Parameters
iterable<

\stdClass>|IResultWrapper $rows

Parameters
string$commentKeyThe comment key to pass through to CommentStore, typically a legacy field name.
string | null$namespaceFieldThe namespace field for the self-link target, or null to have no self-link target.
string | null$titleFieldThe title field for the self-link target, or null to have no self-link target.
string | null$indexFieldThe field to use for array keys in the result, or null to use the same keys as in the input $rows
bool$useBlockWrap the output in standard punctuation and formatting if it's non-empty.
bool$useParenthesesWrap the output with parentheses. Has no effect if $useBlock is false.
Returns
string[] The formatted comment. The key will be the value of the index field if an index field was specified, or the key from the corresponding element of $rows if no index field was specified.

Definition at line 73 of file RowCommentFormatter.php.

References MediaWiki\CommentFormatter\CommentFormatter\createBatch(), and MediaWiki\CommentFormatter\RowCommentFormatter\rows().

◆ rows()

MediaWiki\CommentFormatter\RowCommentFormatter::rows ( $rows)

Format DB rows using a fluent interface.

Pass the return value of this function to CommentBatch::comments().

Example: $comments = $rowCommentFormatter->createBatch() ->comments( $rowCommentFormatter->rows( $rows ) ->commentField( 'img_comment' ) ) ->useBlock( true ) ->execute();

Parameters
Traversable | array$rows
Returns
RowCommentIterator

Definition at line 49 of file RowCommentFormatter.php.

Referenced by MediaWiki\CommentFormatter\RowCommentFormatter\formatRows().


The documentation for this class was generated from the following file: