19 $file = $this->getOption(
'file',
20 __DIR__ .
'/data/CommentFormatter/rc100-2021-07-29.json' );
21 $json = file_get_contents( $file );
23 $this->fatalError(
"Unable to read input file \"$file\"" );
25 $result = json_decode( $json,
true );
26 if ( !isset( $result[
'query'][
'recentchanges'] ) ) {
27 $this->fatalError(
"Invalid JSON data" );
29 $entries = $result[
'query'][
'recentchanges'];
32 foreach ( $entries as $entry ) {
34 'comment' => $entry[
'comment'],
35 'title' => Title::newFromText( $entry[
'title'] )
37 $comments[] = $entry[
'comment'];
40 'CommentFormatter::format' => [
41 'function' =>
function () use ( $inputs ) {
43 $formatter = $this->getServiceContainer()->getCommentFormatter();
44 foreach ( $inputs as $input ) {
53 'CommentFormatter::createBatch' => [
54 'function' =>
function () use ( $inputs ) {
56 $formatter = $this->getServiceContainer()->getCommentFormatter();
58 foreach ( $inputs as $input ) {
59 $comments[] = (
new CommentItem( $input[
'comment'] ) )
60 ->selfLinkTarget( $input[
'title'] );
62 $formatter->createBatch()
63 ->comments( $comments )
68 'CommentFormatter::formatStrings' => [
69 'function' =>
function () use ( $comments ) {
71 $formatter = $this->getServiceContainer()->getCommentFormatter();
72 $formatter->formatStrings( $comments );