MediaWiki master
ApiImportReporter.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Api;
24
29
36 private $mResultArr = [];
37
46 public function reportPage( ?PageIdentity $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo ) {
47 // Add a result entry
48 $r = [];
49
50 if ( $pageIdentity === null ) {
51 # Invalid or non-importable title
52 $r['title'] = $pageInfo['title'];
53 $r['invalid'] = true;
54 } else {
55 $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
56 ApiQueryBase::addTitleInfo( $r, $titleFactory->newFromPageIdentity( $pageIdentity ) );
57 $r['revisions'] = (int)$successCount;
58 }
59
60 $this->mResultArr[] = $r;
61
62 // Piggyback on the parent to do the logging
63 parent::reportPage( $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo );
64 }
65
66 public function getData() {
67 return $this->mResultArr;
68 }
69}
70
72class_alias( ApiImportReporter::class, 'ApiImportReporter' );
Reporting callback.
Import reporter for the API.
reportPage(?PageIdentity $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Interface for objects (potentially) representing an editable wiki page.