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 ( $revisionId, EntityId $redirectsTo)
 
static nonexistentEntity ()
 
static concreteRevision ( $revisionId)
 

Private Member Functions

 __construct ( $type)
 

Static Private Member Functions

static assertCorrectRevisionId ( $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
 
 $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 );
$revisionRedirectsToQ7 = LatestRevisionIdResult::redirect( 123, new ItemId( 'Q7' ) );
static nonexistentEntity()
Definition: LatestRevisionIdResult.php:88
static concreteRevision( $revisionId)
Definition: LatestRevisionIdResult.php:96
static redirect( $revisionId, EntityId $redirectsTo)
Definition: LatestRevisionIdResult.php:75

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:147
$redirectsTo
Definition: LatestRevisionIdResult.php:68
onConcreteRevision(callable $handler)
Definition: LatestRevisionIdResult.php:112
onNonexistentEntity(callable $handler)
Definition: LatestRevisionIdResult.php:135
$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 (   $revisionId)
staticprivate
Parameters
mixed$revisionIdExpected positive integer
Exceptions

◆ concreteRevision()

static Wikibase\Lib\Store\LatestRevisionIdResult::concreteRevision (   $revisionId)
static
Parameters
int$revisionId
Returns
self

◆ 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
Returns
self

◆ onConcreteRevision()

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

◆ onNonexistentEntity()

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

◆ 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
Returns
self

◆ redirect()

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

Member Data Documentation

◆ $handlers

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

◆ $redirectsTo

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

◆ $revisionId

Wikibase\Lib\Store\LatestRevisionIdResult::$revisionId
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: