MediaWiki  master
NamespaceImportTitleFactory.php
Go to the documentation of this file.
1 <?php
23 
31  private $titleFactory;
32 
34  private $ns;
35 
41  public function __construct(
42  NamespaceInfo $namespaceInfo,
43  TitleFactory $titleFactory,
44  int $ns
45  ) {
46  if ( !$namespaceInfo->exists( $ns ) ) {
47  throw new InvalidArgumentException( "Namespace $ns doesn't exist on this wiki" );
48  }
49  $this->titleFactory = $titleFactory;
50  $this->ns = $ns;
51  }
52 
61  public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
62  return $this->titleFactory->makeTitleSafe( $this->ns, $foreignTitle->getText() );
63  }
64 }
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Creates Title objects.
Represents a title within MediaWiki.
Definition: Title.php:82
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 ...