MediaWiki  master
Page\PageReferenceValue Class Reference

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

Inheritance diagram for Page\PageReferenceValue:
Collaboration diagram for Page\PageReferenceValue:

Public Member Functions

 __construct (int $namespace, string $dbKey, $wikiId)
 
 __toString ()
 Returns a string representation of the title, for logging. More...
 
 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
More...
 
 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
More...
 
 getWikiId ()
 Get the ID of the wiki provided to the constructor. More...
 
 isSamePageAs (PageReference $other)
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId(). More...
 

Static Public Member Functions

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

Private Attributes

string $dbKey
 
int $namespace
 
bool string $wikiId
 

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()

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 | bool$wikiIdThe Id of the wiki this page belongs to, or self::LOCAL for the local wiki.

Definition at line 63 of file PageReferenceValue.php.

References Page\PageReferenceValue\$dbKey, Page\PageReferenceValue\$wikiId, and MediaWiki\DAO\assertWikiIdParam().

Member Function Documentation

◆ __toString()

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 Page\PageReference.

Definition at line 141 of file PageReferenceValue.php.

References $s, Page\PageReferenceValue\$wikiId, and if.

◆ getDBkey()

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 Page\PageReference.

Definition at line 110 of file PageReferenceValue.php.

References Page\PageReferenceValue\$dbKey.

◆ getNamespace()

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 Page\PageReference.

Definition at line 101 of file PageReferenceValue.php.

References Page\PageReferenceValue\$namespace.

◆ getWikiId()

Page\PageReferenceValue::getWikiId ( )

Get the ID of the wiki provided to the constructor.

Returns
string|false

Implements Page\PageReference.

Definition at line 92 of file PageReferenceValue.php.

References Page\PageReferenceValue\$wikiId.

Referenced by Page\PageIdentityValue\exists().

◆ isSamePageAs()

Page\PageReferenceValue::isSamePageAs ( PageReference  $other)

◆ localReference()

static 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.

References Page\PageReferenceValue\$dbKey, and Page\PageReferenceValue\$namespace.

Referenced by MediaWiki\Block\BlockErrorFormatter\formatBlockerLink().

Member Data Documentation

◆ $dbKey

◆ $namespace

◆ $wikiId


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