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 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:335
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:134
SubpageImportTitleFactory\createTitleFromForeignTitle
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
Definition: SubpageImportTitleFactory.php:55
SubpageImportTitleFactory\$rootPage
Title $rootPage
Definition: SubpageImportTitleFactory.php:30
ForeignTitle\getFullText
getFullText()
Definition: ForeignTitle.php:89
SubpageImportTitleFactory\__construct
__construct(Title $rootPage)
Definition: SubpageImportTitleFactory.php:36
MWException
MediaWiki exception.
Definition: MWException.php:26
ImportTitleFactory
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...
Definition: ImportTitleFactory.php:25
Title\getNamespace
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:1053
SubpageImportTitleFactory
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Definition: SubpageImportTitleFactory.php:28
Title
Represents a title within MediaWiki.
Definition: Title.php:42
ForeignTitle
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Definition: ForeignTitle.php:28