MediaWiki master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Title;
8
9use InvalidArgumentException;
10
17 private TitleFactory $titleFactory;
18
19 private int $ns;
20
26 public function __construct(
27 NamespaceInfo $namespaceInfo,
28 TitleFactory $titleFactory,
29 int $ns
30 ) {
31 if ( !$namespaceInfo->exists( $ns ) ) {
32 throw new InvalidArgumentException( "Namespace $ns doesn't exist on this wiki" );
33 }
34 $this->titleFactory = $titleFactory;
35 $this->ns = $ns;
36 }
37
46 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
47 return $this->titleFactory->makeTitleSafe( $this->ns, $foreignTitle->getText() );
48 }
49}
50
52class_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 ...