MediaWiki  REL1_24
TitleValue Class Reference

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

Collaboration diagram for TitleValue:

List of all members.

Public Member Functions

 __construct ($namespace, $dbkey, $fragment= '')
 Constructs a TitleValue.
 __toString ()
 Returns a string representation of the title, for logging.
 createFragmentTitle ($fragment)
 Creates a new TitleValue for a different fragment of the same page.
 getDBkey ()
 Returns the title's DB key, as supplied to the constructor, without namespace prefix or fragment.
 getFragment ()
 getNamespace ()
 getText ()
 Returns the title in text form, without namespace prefix or fragment.

Protected Attributes

string $dbkey
string $fragment
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.
TitleValue represents the title of a local page (or fragment of a page). It does not represent a link, and does not support interwiki prefixes etc.
See also:
https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue

Definition at line 36 of file TitleValue.php.


Constructor & Destructor Documentation

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

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.
Exceptions:
InvalidArgumentException

Definition at line 65 of file TitleValue.php.


Member Function Documentation

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 149 of file TitleValue.php.

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

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

Definition at line 138 of file TitleValue.php.

Referenced by TitleValueTest\testCreateFragmentTitle().

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

Returns:
string

Definition at line 112 of file TitleValue.php.

Returns:
string

Definition at line 102 of file TitleValue.php.

Referenced by TitleTest\testNewFromTitleValue().

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

Definition at line 127 of file TitleValue.php.

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


Member Data Documentation

string TitleValue::$dbkey [protected]

Definition at line 43 of file TitleValue.php.

string TitleValue::$fragment [protected]

Definition at line 47 of file TitleValue.php.

int TitleValue::$namespace [protected]

Definition at line 39 of file TitleValue.php.


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