Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Store\LatestRevisionIdResult Class Reference

Represents result of \Wikibase\Lib\Store\EntityRevisionLookup::getLatestRevisionId method call. More...

Public Member Functions

 onConcreteRevision (callable $handler)
 
 onRedirect (callable $handler)
 
 onNonexistentEntity (callable $handler)
 
 map ()
 

Static Public Member Functions

static redirect (int $revisionId, EntityId $redirectsTo)
 
static nonexistentEntity ()
 
static concreteRevision (int $revisionId, string $revisionTimestamp)
 

Private Member Functions

 __construct ( $type)
 

Static Private Member Functions

static assertCorrectRevisionId (int $revisionId)
 

Private Attributes

const REDIRECT = 'redirect'
 Constants to specify type of the result. More...
 
const NONEXISTENT = 'nonexistent'
 
const CONCRETE_REVISION = 'concrete revision'
 
 $type
 
 $handlers = []
 
 $revisionId
 
 $revisionTimestamp
 
 $redirectsTo
 

Detailed Description

Represents result of \Wikibase\Lib\Store\EntityRevisionLookup::getLatestRevisionId method call.

Is immutable.

The idea behind the design is to force developer to handle all the possible cases.

How to create:

$concreteRevision = LatestRevisionIdResult::concreteRevision( 123, '20220101001122' );
$revisionRedirectsToQ7 = LatestRevisionIdResult::redirect( 123, new ItemId( 'Q7' ) );
static concreteRevision(int $revisionId, string $revisionTimestamp)
Definition: LatestRevisionIdResult.php:93
static nonexistentEntity()
Definition: LatestRevisionIdResult.php:89
static redirect(int $revisionId, EntityId $redirectsTo)
Definition: LatestRevisionIdResult.php:79

Example of usage:

$result = $someResult->onRedirect( function ( int $revisionId, EntityId $redirectsTo ) {
return 'redirect';
} )
->onNonexistentEntity( function () {
return 'nonexistent';
} )
->onConcreteRevision( function ( int $revisionId ) {
return 'concrete';
} )
->map();
// $result will be one of 'redirect', 'nonexistent' or 'concrete' depending
// on the $someResult type
map()
Definition: LatestRevisionIdResult.php:142
$redirectsTo
Definition: LatestRevisionIdResult.php:73
onConcreteRevision(callable $handler)
Definition: LatestRevisionIdResult.php:109
onNonexistentEntity(callable $handler)
Definition: LatestRevisionIdResult.php:130
$revisionId
Definition: LatestRevisionIdResult.php:63
See also
\Wikibase\Lib\Store\EntityRevisionLookup::getLatestRevisionId

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Store\LatestRevisionIdResult::__construct (   $type)
private

Member Function Documentation

◆ assertCorrectRevisionId()

static Wikibase\Lib\Store\LatestRevisionIdResult::assertCorrectRevisionId ( int  $revisionId)
staticprivate
Parameters
int$revisionIdExpected positive integer
Exceptions

◆ concreteRevision()

static Wikibase\Lib\Store\LatestRevisionIdResult::concreteRevision ( int  $revisionId,
string  $revisionTimestamp 
)
static

◆ map()

Wikibase\Lib\Store\LatestRevisionIdResult::map ( )
Returns
mixed Returns value returned by one of the map functions
Exceptions

◆ nonexistentEntity()

static Wikibase\Lib\Store\LatestRevisionIdResult::nonexistentEntity ( )
static

◆ onConcreteRevision()

Wikibase\Lib\Store\LatestRevisionIdResult::onConcreteRevision ( callable  $handler)
Parameters
callable$handlerRevision id will be given as a first argument

◆ onNonexistentEntity()

Wikibase\Lib\Store\LatestRevisionIdResult::onNonexistentEntity ( callable  $handler)
Parameters
callable$handlerFunction with no arguments

◆ onRedirect()

Wikibase\Lib\Store\LatestRevisionIdResult::onRedirect ( callable  $handler)
Parameters
callable$handlerRevision id will be given as a first argument, EntityId to which revision redirects will be second argument

◆ redirect()

static Wikibase\Lib\Store\LatestRevisionIdResult::redirect ( int  $revisionId,
EntityId  $redirectsTo 
)
static
Parameters
int$revisionId
EntityId$redirectsTo(could be another redirect)

Member Data Documentation

◆ $handlers

Wikibase\Lib\Store\LatestRevisionIdResult::$handlers = []
private

◆ $redirectsTo

Wikibase\Lib\Store\LatestRevisionIdResult::$redirectsTo
private

◆ $revisionId

Wikibase\Lib\Store\LatestRevisionIdResult::$revisionId
private

◆ $revisionTimestamp

Wikibase\Lib\Store\LatestRevisionIdResult::$revisionTimestamp
private

◆ $type

Wikibase\Lib\Store\LatestRevisionIdResult::$type
private

◆ CONCRETE_REVISION

const Wikibase\Lib\Store\LatestRevisionIdResult::CONCRETE_REVISION = 'concrete revision'
private

◆ NONEXISTENT

const Wikibase\Lib\Store\LatestRevisionIdResult::NONEXISTENT = 'nonexistent'
private

◆ REDIRECT

const Wikibase\Lib\Store\LatestRevisionIdResult::REDIRECT = 'redirect'
private

Constants to specify type of the result.


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