MediaWiki master
SubpageImportTitleFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Title;
22
23use InvalidArgumentException;
24
31 private TitleFactory $titleFactory;
32 private Title $rootPage;
33
39 public function __construct(
40 NamespaceInfo $namespaceInfo,
41 TitleFactory $titleFactory,
42 Title $rootPage
43 ) {
44 if ( !$namespaceInfo->hasSubpages( $rootPage->getNamespace() ) ) {
45 throw new InvalidArgumentException( "The root page you specified, $rootPage, is in a " .
46 "namespace where subpages are not allowed" );
47 }
48 $this->titleFactory = $titleFactory;
49 $this->rootPage = $rootPage;
50 }
51
60 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
61 return $this->titleFactory->newFromText(
62 $this->rootPage->getPrefixedDBkey() . '/' . $foreignTitle->getFullText()
63 );
64 }
65}
66
68class_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 ...