MediaWiki  master
SubpageImportTitleFactory.php
Go to the documentation of this file.
1 <?php
22 
30  protected $rootPage;
31 
36  public function __construct( Title $rootPage ) {
37  if (
38  !MediaWikiServices::getInstance()->getNamespaceInfo()->
39  hasSubpages( $rootPage->getNamespace() )
40  ) {
41  throw new MWException( "The root page you specified, $rootPage, is in a " .
42  "namespace where subpages are not allowed" );
43  }
44  $this->rootPage = $rootPage;
45  }
46 
55  public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
56  return Title::newFromText( $this->rootPage->getPrefixedDBkey() . '/' .
57  $foreignTitle->getFullText() );
58  }
59 }
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:1035
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:317