MediaWiki  master
Page\PageIdentityValue Class Reference

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

Inheritance diagram for Page\PageIdentityValue:
Collaboration diagram for Page\PageIdentityValue:

Public Member Functions

 __construct (int $pageId, int $namespace, string $dbKey, $wikiId)
 
 canExist ()
 
 exists ()
 Returns whether the page currently exists. More...
 
 getId ( $wikiId=self::LOCAL)
 The numerical page ID provided to the constructor. More...
 
- Public Member Functions inherited from Page\PageReferenceValue
 __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...
 
- Public Member Functions inherited from Page\ProperPageIdentity
 getDBkey ()
 Get the page title in DB key form. More...
 
 getWikiId ()
 Get the ID of the wiki this page belongs to. More...
 

Static Public Member Functions

static localIdentity (int $pageId, int $namespace, string $dbKey)
 Create PageIdentity for a local page. More...
 
static tryNew (int $pageId, int $namespace, string $dbKey, $wikiId)
 Constructs a PageIdentityValue, or returns null if the parameters are not valid. More...
 
- Static Public Member Functions inherited from Page\PageReferenceValue
static localReference (int $namespace, string $dbKey)
 Create PageReference for a local page. More...
 

Private Attributes

int $pageId
 

Detailed Description

Immutable value object representing a page identity.

Instances of this class are expected to always represent proper pages, that is, pages that can at least potentially exist as editable pages on the wiki. This class cannot represent Special pages, interwiki links, section links, etc.

Code that deserializes instances of PageIdentityValue must ensure that the original meaning of the "local" Wiki ID is preserved: When an instance of PageIdentityValue 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.36

Definition at line 41 of file PageIdentityValue.php.

Constructor & Destructor Documentation

◆ __construct()

Page\PageIdentityValue::__construct ( int  $pageId,
int  $namespace,
string  $dbKey,
  $wikiId 
)
Parameters
int$pageIdThe ID of this page, or 0 if the page does not exist.
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 76 of file PageIdentityValue.php.

References Page\PageReferenceValue\$dbKey, Page\PageReferenceValue\$namespace, Page\PageIdentityValue\$pageId, and Page\PageReferenceValue\$wikiId.

Member Function Documentation

◆ canExist()

Page\PageIdentityValue::canExist ( )
Returns
bool always true

Implements Page\ProperPageIdentity.

Definition at line 129 of file PageIdentityValue.php.

◆ exists()

Page\PageIdentityValue::exists ( )

Returns whether the page currently exists.

Returns true if getId() returns a value greater than zero.

Returns
bool

Implements Page\PageIdentity.

Definition at line 122 of file PageIdentityValue.php.

References Page\PageIdentityValue\getId(), and Page\PageReferenceValue\getWikiId().

◆ getId()

Page\PageIdentityValue::getId (   $wikiId = self::LOCAL)

The numerical page ID provided to the constructor.

Parameters
string | false$wikiIdThe wiki ID expected by the caller. Omit if expecting the local wiki.
Returns
int

Implements Page\ProperPageIdentity.

Definition at line 112 of file PageIdentityValue.php.

References Page\PageIdentityValue\$pageId, Page\PageReferenceValue\$wikiId, and MediaWiki\DAO\WikiAwareEntity\assertWiki().

Referenced by Page\PageIdentityValue\exists().

◆ localIdentity()

static Page\PageIdentityValue::localIdentity ( int  $pageId,
int  $namespace,
string  $dbKey 
)
static

Create PageIdentity for a local page.

Parameters
int$pageId
int$namespace
string$dbKey
Returns
PageIdentityValue

Definition at line 100 of file PageIdentityValue.php.

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

◆ tryNew()

static Page\PageIdentityValue::tryNew ( int  $pageId,
int  $namespace,
string  $dbKey,
  $wikiId 
)
static

Constructs a PageIdentityValue, or returns null if the parameters are not valid.

Note
This does not perform any normalization, and only basic validation. For full normalization and validation, use TitleParser::makeTitleValueSafe() together with PageLookup::getPageForLink().
Parameters
int$pageIdThe ID of this page, or 0 if the page does not exist.
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.
Returns
PageIdentityValue|null

Definition at line 61 of file PageIdentityValue.php.

References Page\PageReferenceValue\$dbKey, Page\PageReferenceValue\$namespace, Page\PageIdentityValue\$pageId, and Page\PageReferenceValue\$wikiId.

Member Data Documentation

◆ $pageId


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