MediaWiki  master
TitleValue Class Reference

Represents a page (or page fragment) title within MediaWiki. More...

Inheritance diagram for TitleValue:
Collaboration diagram for TitleValue:

Public Member Functions

 __construct ($namespace, $dbkey, $fragment= '', $interwiki= '')
 Constructs a TitleValue. More...
 
 __toString ()
 Returns a string representation of the title, for logging. More...
 
 createFragmentTarget ($fragment)
 Creates a new TitleValue for a different fragment of the same page. More...
 
 getDBkey ()
 Returns the title's DB key, as supplied to the constructor, without namespace prefix or fragment. More...
 
 getFragment ()
 
 getInterwiki ()
 Returns the interwiki part. More...
 
 getNamespace ()
 
 getText ()
 Returns the title in text form, without namespace prefix or fragment. More...
 
 hasFragment ()
 
 inNamespace ($ns)
 
 isExternal ()
 Whether it has an interwiki part. More...
 

Protected Attributes

string $dbkey
 
string $fragment
 
string $interwiki
 
int $namespace
 

Detailed Description

Represents a page (or page fragment) title within MediaWiki.

Note
In contrast to Title, this is designed to be a plain value object. That is, it is immutable, does not use global state, and causes no side effects.
See also
https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
Since
1.23

Definition at line 36 of file TitleValue.php.

Constructor & Destructor Documentation

TitleValue::__construct (   $namespace,
  $dbkey,
  $fragment = '',
  $interwiki = '' 
)

Constructs a TitleValue.

Note
TitleValue expects a valid DB key; typically, a TitleValue is constructed either from a database entry, or by a TitleParser. We could apply "some" normalization here, such as substituting spaces by underscores, but that would encourage the use of un-normalized text when constructing TitleValues. For constructing a TitleValue from user input or external sources, use a TitleParser.
Parameters
int$namespaceThe namespace ID. This is not validated.
string$dbkeyThe page title in valid DBkey form. No normalization is applied.
string$fragmentThe fragment title. Use '' to represent the whole page. No validation or normalization is applied.
string$interwikiThe interwiki component
Exceptions
InvalidArgumentException

Definition at line 74 of file TitleValue.php.

References $dbkey, $fragment, and $interwiki.

Member Function Documentation

TitleValue::__toString ( )

Returns a string representation of the title, for logging.

This is purely informative and must not be used programmatically. Use the appropriate TitleFormatter to generate the correct string representation for a given use.

Returns
string

Definition at line 191 of file TitleValue.php.

References $fragment, $name, and if.

TitleValue::createFragmentTarget (   $fragment)

Creates a new TitleValue for a different fragment of the same page.

Since
1.27
Parameters
string$fragmentThe fragment name, or "" for the entire page.
Returns
TitleValue

Implements MediaWiki\Linker\LinkTarget.

Definition at line 155 of file TitleValue.php.

Referenced by TitleValueTest\testCreateFragmentTitle().

TitleValue::getDBkey ( )

Returns the title's DB key, as supplied to the constructor, without namespace prefix or fragment.

Returns
string

Implements MediaWiki\Linker\LinkTarget.

Definition at line 128 of file TitleValue.php.

References $dbkey.

Referenced by LinkCache\getMutableCacheKeys(), and getText().

TitleValue::getFragment ( )
Returns
string

Implements MediaWiki\Linker\LinkTarget.

Definition at line 110 of file TitleValue.php.

References $fragment.

Referenced by TitleTest\testNewFromTitleValue().

TitleValue::getInterwiki ( )

Returns the interwiki part.

Since
1.27
Returns
string

Implements MediaWiki\Linker\LinkTarget.

Definition at line 180 of file TitleValue.php.

References $interwiki.

TitleValue::getNamespace ( )
TitleValue::getText ( )

Returns the title in text form, without namespace prefix or fragment.

This is computed from the DB key by replacing any underscores with spaces.

Note
To get a title string that includes the namespace and/or fragment, use a TitleFormatter.
Returns
string

Implements MediaWiki\Linker\LinkTarget.

Definition at line 143 of file TitleValue.php.

References getDBkey().

Referenced by WANCacheReapUpdate\getEventAffectedKeys(), TitleValueTest\testCreateFragmentTitle(), and TitleTest\testNewFromTitleValue().

TitleValue::hasFragment ( )
Since
1.27
Returns
bool

Implements MediaWiki\Linker\LinkTarget.

Definition at line 118 of file TitleValue.php.

TitleValue::inNamespace (   $ns)
Since
1.27
Parameters
int$ns
Returns
bool

Implements MediaWiki\Linker\LinkTarget.

Definition at line 103 of file TitleValue.php.

Referenced by WANCacheReapUpdate\getEventAffectedKeys().

TitleValue::isExternal ( )

Whether it has an interwiki part.

Since
1.27
Returns
bool

Implements MediaWiki\Linker\LinkTarget.

Definition at line 170 of file TitleValue.php.

Member Data Documentation

string TitleValue::$dbkey
protected

Definition at line 45 of file TitleValue.php.

Referenced by __construct(), and getDBkey().

string TitleValue::$fragment
protected

Definition at line 50 of file TitleValue.php.

Referenced by __construct(), __toString(), and getFragment().

string TitleValue::$interwiki
protected

Definition at line 55 of file TitleValue.php.

Referenced by __construct(), and getInterwiki().

int TitleValue::$namespace
protected

Definition at line 40 of file TitleValue.php.

Referenced by getNamespace().


The documentation for this class was generated from the following file: