MediaWiki REL1_34
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}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
Represents a title within MediaWiki.
Definition Title.php:42
getNamespace()
Get the namespace index, i.e.
Definition Title.php:1037
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...