Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck Class Reference

Wrapper around an ItemRevisionMetadataRetriever and ConditionalHeaderUtil to check whether a request meets the preconditions for a certain response code. More...

+ Collaboration diagram for Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck:

Public Member Functions

 __construct (EntityRevisionLookup $revisionLookup, EntityIdParser $entityIdParser, callable $getEntityIdFromRequest, ConditionalHeaderUtil $conditionalHeaderUtil)
 
 checkPreconditions (RequestInterface $request)
 

Static Public Member Functions

static getSubjectIdPrefixFromStatementId (string $statementId)
 Convenience function to use with the $getEntityIdFromRequest callable and dealing with statement IDs.
 

Private Member Functions

 getCheckResultFromRequestAndMetadata (RequestInterface $request, int $revisionId, string $revisionTimestamp)
 

Private Attributes

EntityRevisionLookup $revisionLookup
 
EntityIdParser $entityIdParser
 
 $getEntityIdFromRequest
 
ConditionalHeaderUtil $conditionalHeaderUtil
 

Detailed Description

Wrapper around an ItemRevisionMetadataRetriever and ConditionalHeaderUtil to check whether a request meets the preconditions for a certain response code.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::__construct ( EntityRevisionLookup $revisionLookup,
EntityIdParser $entityIdParser,
callable $getEntityIdFromRequest,
ConditionalHeaderUtil $conditionalHeaderUtil )

Member Function Documentation

◆ checkPreconditions()

Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::checkPreconditions ( RequestInterface $request)

Calling an EntityRevisionLookup directly from the middleware violates the "flow of control" rule as it bypasses the input port and domain layer (see the 4th bullet point in ADR 1). We have made the conscious decision to allow an exception for the following reasons:

  • The middleware is quite isolated and can easily be reimplement
  • Doing this "properly" would result in more complex code and tests without much added value except for "following the rules"

◆ getCheckResultFromRequestAndMetadata()

Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::getCheckResultFromRequestAndMetadata ( RequestInterface $request,
int $revisionId,
string $revisionTimestamp )
private

◆ getSubjectIdPrefixFromStatementId()

static Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::getSubjectIdPrefixFromStatementId ( string $statementId)
static

Convenience function to use with the $getEntityIdFromRequest callable and dealing with statement IDs.

Member Data Documentation

◆ $conditionalHeaderUtil

ConditionalHeaderUtil Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::$conditionalHeaderUtil
private

◆ $entityIdParser

EntityIdParser Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::$entityIdParser
private

◆ $getEntityIdFromRequest

Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::$getEntityIdFromRequest
private

◆ $revisionLookup

EntityRevisionLookup Wikibase\Repo\RestApi\RouteHandlers\Middleware\RequestPreconditionCheck::$revisionLookup
private

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