MediaWiki  master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1 <?php
22 
30  private $titleFactory;
31 
33  private $ns;
34 
40  public function __construct(
41  NamespaceInfo $namespaceInfo,
42  TitleFactory $titleFactory,
43  int $ns
44  ) {
45  if ( !$namespaceInfo->exists( $ns ) ) {
46  throw new MWException( "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 }
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
MediaWiki exception.
Definition: MWException.php:29
Creates Title objects.
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.
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...