MediaWiki REL1_37
SubpageImportTitleFactory.php
Go to the documentation of this file.
1<?php
29
31 private $rootPage;
32
38 public function __construct(
39 NamespaceInfo $namespaceInfo,
42 ) {
43 if ( !$namespaceInfo->hasSubpages( $rootPage->getNamespace() ) ) {
44 throw new MWException( "The root page you specified, $rootPage, is in a " .
45 "namespace where subpages are not allowed" );
46 }
47 $this->titleFactory = $titleFactory;
48 $this->rootPage = $rootPage;
49 }
50
59 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
60 return $this->titleFactory->newFromText(
61 $this->rootPage->getPrefixedDBkey() . '/' . $foreignTitle->getFullText()
62 );
63 }
64}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
MediaWiki exception.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
hasSubpages( $index)
Does the namespace allow subpages? Note that this refers to structured handling of subpages,...
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.
__construct(NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, Title $rootPage)
Creates Title objects.
Represents a title within MediaWiki.
Definition Title.php:48
getNamespace()
Get the namespace index, i.e.
Definition Title.php:1078
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...