MediaWiki master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Title;
22
23use InvalidArgumentException;
24
32 private $titleFactory;
33
35 private $ns;
36
42 public function __construct(
43 NamespaceInfo $namespaceInfo,
44 TitleFactory $titleFactory,
45 int $ns
46 ) {
47 if ( !$namespaceInfo->exists( $ns ) ) {
48 throw new InvalidArgumentException( "Namespace $ns doesn't exist on this wiki" );
49 }
50 $this->titleFactory = $titleFactory;
51 $this->ns = $ns;
52 }
53
62 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
63 return $this->titleFactory->makeTitleSafe( $this->ns, $foreignTitle->getText() );
64 }
65}
66
68class_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 ...