MediaWiki master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Title;
22
23use InvalidArgumentException;
24
31 private TitleFactory $titleFactory;
32
33 private int $ns;
34
40 public function __construct(
41 NamespaceInfo $namespaceInfo,
42 TitleFactory $titleFactory,
43 int $ns
44 ) {
45 if ( !$namespaceInfo->exists( $ns ) ) {
46 throw new InvalidArgumentException( "Namespace $ns doesn't exist on this wiki" );
47 }
48 $this->titleFactory = $titleFactory;
49 $this->ns = $ns;
50 }
51
60 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
61 return $this->titleFactory->makeTitleSafe( $this->ns, $foreignTitle->getText() );
62 }
63}
64
66class_alias( NamespaceImportTitleFactory::class, 'NamespaceImportTitleFactory' );
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
__construct(NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, int $ns)
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
exists( $index)
Returns whether the specified namespace exists.
Creates Title objects.
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...