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 
132  public function newFromIDs( $ids ): array {
133  wfDeprecated( __METHOD__, '1.38' );
134  return Title::newFromIDs( $ids );
135  }
136 
142  public function newFromRow( $row ): Title {
143  return Title::newFromRow( $row );
144  }
145 
154  public function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ): Title {
155  return Title::makeTitle( $ns, $title, $fragment, $interwiki );
156  }
157 
166  public function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ): ?Title {
167  return Title::makeTitleSafe( $ns, $title, $fragment, $interwiki );
168  }
169 
175  public function newMainPage( MessageLocalizer $localizer = null ): Title {
176  return Title::newMainPage( $localizer );
177  }
178 
179 }
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:377
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:710
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:326
TitleFactory\makeTitleSafe
makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Definition: TitleFactory.php:166
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition: GlobalFunctions.php:997
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:577
$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:648
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:412
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:674
TitleFactory\castFromPageReference
castFromPageReference(?PageReference $pageReference)
Definition: TitleFactory.php:81
TitleFactory\newMainPage
newMainPage(MessageLocalizer $localizer=null)
Definition: TitleFactory.php:175
TitleFactory\castFromLinkTarget
castFromLinkTarget(?LinkTarget $linkTarget)
Definition: TitleFactory.php:61
TitleFactory\newFromRow
newFromRow( $row)
Definition: TitleFactory.php:142
Title\newFromDBkey
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
Definition: Title.php:250
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:474
Title\newFromIDs
static newFromIDs( $ids)
Make an array of titles from an array of IDs.
Definition: Title.php:549
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:289
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:47
TitleFactory\newFromIDs
newFromIDs( $ids)
Definition: TitleFactory.php:132
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:35
TitleFactory\makeTitle
makeTitle( $ns, $title, $fragment='', $interwiki='')
Definition: TitleFactory.php:154
Title\castFromPageReference
static castFromPageReference(?PageReference $pageReference)
Return a Title for a given Reference.
Definition: Title.php:339
Title\castFromLinkTarget
static castFromLinkTarget( $linkTarget)
Same as newFromLinkTarget, but if passed null, returns null.
Definition: Title.php:313
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:523
TitleFactory\newFromLinkTarget
newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Definition: TitleFactory.php:52