MediaWiki  master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1 <?php
28  private $titleFactory;
29 
31  private $ns;
32 
38  public function __construct(
39  NamespaceInfo $namespaceInfo,
41  int $ns
42  ) {
43  if ( !$namespaceInfo->exists( $ns ) ) {
44  throw new MWException( "Namespace $ns doesn't exist on this wiki" );
45  }
46  $this->titleFactory = $titleFactory;
47  $this->ns = $ns;
48  }
49 
58  public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
59  return $this->titleFactory->makeTitleSafe( $this->ns, $foreignTitle->getText() );
60  }
61 }
NamespaceImportTitleFactory\createTitleFromForeignTitle
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
Definition: NamespaceImportTitleFactory.php:58
ForeignTitle\getText
getText()
Definition: ForeignTitle.php:84
NamespaceImportTitleFactory
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Definition: NamespaceImportTitleFactory.php:26
NamespaceImportTitleFactory\$ns
int $ns
Definition: NamespaceImportTitleFactory.php:31
NamespaceImportTitleFactory\__construct
__construct(NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, int $ns)
Definition: NamespaceImportTitleFactory.php:38
MWException
MediaWiki exception.
Definition: MWException.php:29
ImportTitleFactory
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...
Definition: ImportTitleFactory.php:25
NamespaceImportTitleFactory\$titleFactory
TitleFactory $titleFactory
Definition: NamespaceImportTitleFactory.php:28
NamespaceInfo\exists
exists( $index)
Returns whether the specified namespace exists.
Definition: NamespaceInfo.php:338
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:35
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
ForeignTitle
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Definition: ForeignTitle.php:28