MediaWiki  master
ApiImportReporter.php
Go to the documentation of this file.
1 <?php
25 
31  private $mResultArr = [];
32 
41  public function reportPage( ?PageIdentity $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo ) {
42  // Add a result entry
43  $r = [];
44 
45  if ( $pageIdentity === null ) {
46  # Invalid or non-importable title
47  $r['title'] = $pageInfo['title'];
48  $r['invalid'] = true;
49  } else {
50  $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
51  ApiQueryBase::addTitleInfo( $r, $titleFactory->castFromPageIdentity( $pageIdentity ) );
52  $r['revisions'] = (int)$successCount;
53  }
54 
55  $this->mResultArr[] = $r;
56 
57  // Piggyback on the parent to do the logging
58  parent::reportPage( $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo );
59  }
60 
61  public function getData() {
62  return $this->mResultArr;
63  }
64 }
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:64
ApiImportReporter\$mResultArr
$mResultArr
Definition: ApiImportReporter.php:31
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:200
ImportReporter
Reporting callback.
Definition: ImportReporter.php:29
ApiImportReporter\reportPage
reportPage(?PageIdentity $pageIdentity, $foreignTitle, $revisionCount, $successCount, $pageInfo)
Definition: ApiImportReporter.php:41
ApiImportReporter\getData
getData()
Definition: ApiImportReporter.php:61
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:466
ApiImportReporter
Import reporter for the API.
Definition: ApiImportReporter.php:30