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