MediaWiki  master
SubpageImportTitleFactory.php
Go to the documentation of this file.
1 <?php
22 
30  private $titleFactory;
31 
33  private $rootPage;
34 
40  public function __construct(
41  NamespaceInfo $namespaceInfo,
42  TitleFactory $titleFactory,
43  Title $rootPage
44  ) {
45  if ( !$namespaceInfo->hasSubpages( $rootPage->getNamespace() ) ) {
46  throw new MWException( "The root page you specified, $rootPage, is in a " .
47  "namespace where subpages are not allowed" );
48  }
49  $this->titleFactory = $titleFactory;
50  $this->rootPage = $rootPage;
51  }
52 
61  public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
62  return $this->titleFactory->newFromText(
63  $this->rootPage->getPrefixedDBkey() . '/' . $foreignTitle->getFullText()
64  );
65  }
66 }
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
MediaWiki exception.
Definition: MWException.php:29
Creates Title objects.
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)
Represents a title within MediaWiki.
Definition: Title.php:52
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:1069
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...