MediaWiki  master
TitleFactory.php
Go to the documentation of this file.
1 <?php
26 
35 class TitleFactory {
36 
42  public function newFromDBkey( $key ): ?Title {
43  return Title::newFromDBkey( $key );
44  }
45 
52  public function newFromLinkTarget( LinkTarget $linkTarget, $forceClone = '' ): Title {
53  return Title::newFromLinkTarget( $linkTarget, $forceClone );
54  }
55 
61  public function castFromLinkTarget( ?LinkTarget $linkTarget ): ?Title {
62  return Title::castFromLinkTarget( $linkTarget );
63  }
64 
71  public function castFromPageIdentity( ?PageIdentity $pageIdentity ): ?Title {
72  return Title::castFromPageIdentity( $pageIdentity );
73  }
74 
81  public function castFromPageReference( ?PageReference $pageReference ): ?Title {
82  return Title::castFromPageReference( $pageReference );
83  }
84 
92  public function newFromText( $text, $defaultNamespace = NS_MAIN ): ?Title {
93  return Title::newFromText( $text, $defaultNamespace );
94  }
95 
103  public function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ): Title {
104  return Title::newFromTextThrow( $text, $defaultNamespace );
105  }
106 
112  public function newFromURL( $url ): ?Title {
113  return Title::newFromURL( $url );
114  }
115 
122  public function newFromID( $id, $flags = 0 ): ?Title {
123  return Title::newFromID( $id, $flags );
124  }
125 
131  public function newFromIDs( $ids ): array {
132  return Title::newFromIDs( $ids );
133  }
134 
140  public function newFromRow( $row ): Title {
141  return Title::newFromRow( $row );
142  }
143 
152  public function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ): Title {
153  return Title::makeTitle( $ns, $title, $fragment, $interwiki );
154  }
155 
164  public function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ): ?Title {
165  return Title::makeTitleSafe( $ns, $title, $fragment, $interwiki );
166  }
167 
173  public function newMainPage( MessageLocalizer $localizer = null ): Title {
174  return Title::newMainPage( $localizer );
175  }
176 
177 }
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:64
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:383
TitleFactory\newFromTextThrow
newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Definition: TitleFactory.php:103
TitleFactory\newFromText
newFromText( $text, $defaultNamespace=NS_MAIN)
Definition: TitleFactory.php:92
TitleFactory\newFromID
newFromID( $id, $flags=0)
Definition: TitleFactory.php:122
Title\newMainPage
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
Definition: Title.php:713
Page\PageReference
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
Definition: PageReference.php:49
MessageLocalizer
Interface for localizing messages in MediaWiki.
Definition: MessageLocalizer.php:29
NS_MAIN
const NS_MAIN
Definition: Defines.php:64
Title\castFromPageIdentity
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
Definition: Title.php:332
TitleFactory\makeTitleSafe
makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Definition: TitleFactory.php:164
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:580
$title
$title
Definition: testCompression.php:38
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:651
TitleFactory\newFromDBkey
newFromDBkey( $key)
Definition: TitleFactory.php:42
Title\newFromTextThrow
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
Definition: Title.php:418
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:677
TitleFactory\castFromPageReference
castFromPageReference(?PageReference $pageReference)
Definition: TitleFactory.php:81
TitleFactory\newMainPage
newMainPage(MessageLocalizer $localizer=null)
Definition: TitleFactory.php:173
TitleFactory\castFromLinkTarget
castFromLinkTarget(?LinkTarget $linkTarget)
Definition: TitleFactory.php:61
TitleFactory\newFromRow
newFromRow( $row)
Definition: TitleFactory.php:140
Title\newFromDBkey
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
Definition: Title.php:256
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:480
Title\newFromIDs
static newFromIDs( $ids)
Make an array of titles from an array of IDs.
Definition: Title.php:554
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:295
TitleFactory\newFromURL
newFromURL( $url)
Definition: TitleFactory.php:112
TitleFactory\castFromPageIdentity
castFromPageIdentity(?PageIdentity $pageIdentity)
Definition: TitleFactory.php:71
Title
Represents a title within MediaWiki.
Definition: Title.php:48
TitleFactory\newFromIDs
newFromIDs( $ids)
Definition: TitleFactory.php:131
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:35
TitleFactory\makeTitle
makeTitle( $ns, $title, $fragment='', $interwiki='')
Definition: TitleFactory.php:152
Title\castFromPageReference
static castFromPageReference(?PageReference $pageReference)
Return a Title for a given Reference.
Definition: Title.php:345
Title\castFromLinkTarget
static castFromLinkTarget( $linkTarget)
Same as newFromLinkTarget, but if passed null, returns null.
Definition: Title.php:319
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:529
TitleFactory\newFromLinkTarget
newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Definition: TitleFactory.php:52