MediaWiki  master
SubpageImportTitleFactory.php
Go to the documentation of this file.
1 <?php
28  private $titleFactory;
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 }
SubpageImportTitleFactory\$titleFactory
TitleFactory $titleFactory
Definition: SubpageImportTitleFactory.php:28
SubpageImportTitleFactory\createTitleFromForeignTitle
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
Definition: SubpageImportTitleFactory.php:59
SubpageImportTitleFactory\$rootPage
Title $rootPage
Definition: SubpageImportTitleFactory.php:31
ForeignTitle\getFullText
getFullText()
Definition: ForeignTitle.php:89
NamespaceInfo\hasSubpages
hasSubpages( $index)
Does the namespace allow subpages? Note that this refers to structured handling of subpages,...
Definition: NamespaceInfo.php:496
SubpageImportTitleFactory\__construct
__construct(NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, Title $rootPage)
Definition: SubpageImportTitleFactory.php:38
MWException
MediaWiki exception.
Definition: MWException.php:29
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:1097
SubpageImportTitleFactory
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Definition: SubpageImportTitleFactory.php:26
Title
Represents a title within MediaWiki.
Definition: Title.php:49
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:35
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
ForeignTitle
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Definition: ForeignTitle.php:28