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