MediaWiki master
MediaWiki\Page\PageReferenceValue Class Reference

Immutable value object representing a page reference. More...

Inherits MediaWiki\Page\PageReference.

Inherited by MediaWiki\Page\PageIdentityValue.

Collaboration diagram for MediaWiki\Page\PageReferenceValue:

Public Member Functions

 __construct (int $namespace, string $dbKey, $wikiId)
 
 __toString ()
 Returns a string representation of the title, for logging.
 
 getDBkey ()
 Get the page title in DB key form.
Note
This may return a string starting with a hash, if the PageReference represents the target of a block or unblock operation. This is due to the way the block target is represented in the logging table. This is intended to change in the future.
This may return an empty string, if this PageReference is a Title that represents a relative section link. This is intended to change in the future.
Returns
string

 
 getNamespace ()
 Returns the page's namespace number.The value returned by this method should represent a valid namespace, but this cannot be guaranteed in all cases.
Returns
int

 
 getWikiId ()
 Get the ID of the wiki provided to the constructor.
 
 isSamePageAs (PageReference $other)
 Checks whether the given PageReference refers to the same page as this PageReference.Two PageReference instances are considered to refer to the same page if they belong to the same wiki, and have the same namespace and DB key.
Parameters
PageReference$other
Returns
bool

 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Static Public Member Functions

static localReference (int $namespace, string $dbKey)
 Create PageReference for a local page.
 

Detailed Description

Immutable value object representing a page reference.

Instances of this class are expected to always represent a viewable pages, that is, pages that can at least potentially be visited on the wiki. This class may represent Special pages, but not interwiki links, section links, etc.

Code that deserializes instances of PageReferenceValue must ensure that the original meaning of the "local" Wiki ID is preserved: When an instance of PageReferenceValue is created with self::LOCAL as the Wiki ID on one wiki, gets serialized, stored, and later read and unserialized on another wiki, the value of the Wiki ID must be adjusted to refer to the original wiki.

Since
1.37

Definition at line 42 of file PageReferenceValue.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\PageReferenceValue::__construct ( int  $namespace,
string  $dbKey,
  $wikiId 
)
Parameters
int$namespaceA valid namespace ID. Validation is the caller's responsibility!
string$dbKeyA valid DB key. Validation is the caller's responsibility!
string | false$wikiIdThe Id of the wiki this page belongs to, or self::LOCAL for the local wiki.

Definition at line 63 of file PageReferenceValue.php.

Member Function Documentation

◆ __toString()

MediaWiki\Page\PageReferenceValue::__toString ( )

Returns a string representation of the title, for logging.

This is purely informative and must not be used programmatically.

Returns
string

Implements MediaWiki\Page\PageReference.

Definition at line 131 of file PageReferenceValue.php.

◆ getDBkey()

MediaWiki\Page\PageReferenceValue::getDBkey ( )

Get the page title in DB key form.

Note
This may return a string starting with a hash, if the PageReference represents the target of a block or unblock operation. This is due to the way the block target is represented in the logging table. This is intended to change in the future.
This may return an empty string, if this PageReference is a Title that represents a relative section link. This is intended to change in the future.
Returns
string

Returns
string

Implements MediaWiki\Page\PageReference.

Definition at line 110 of file PageReferenceValue.php.

◆ getNamespace()

MediaWiki\Page\PageReferenceValue::getNamespace ( )

Returns the page's namespace number.The value returned by this method should represent a valid namespace, but this cannot be guaranteed in all cases.

Returns
int

Returns
int

Implements MediaWiki\Page\PageReference.

Definition at line 101 of file PageReferenceValue.php.

◆ getWikiId()

MediaWiki\Page\PageReferenceValue::getWikiId ( )

Get the ID of the wiki provided to the constructor.

Returns
string|false

Implements MediaWiki\Page\PageReference.

Definition at line 92 of file PageReferenceValue.php.

◆ isSamePageAs()

MediaWiki\Page\PageReferenceValue::isSamePageAs ( PageReference  $other)

Checks whether the given PageReference refers to the same page as this PageReference.Two PageReference instances are considered to refer to the same page if they belong to the same wiki, and have the same namespace and DB key.

Parameters
PageReference$other
Returns
bool

Implements MediaWiki\Page\PageReference.

Definition at line 117 of file PageReferenceValue.php.

◆ localReference()

static MediaWiki\Page\PageReferenceValue::localReference ( int  $namespace,
string  $dbKey 
)
static

Create PageReference for a local page.

Parameters
int$namespace
string$dbKey
Returns
PageReferenceValue

Definition at line 83 of file PageReferenceValue.php.


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