Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\LinkedData\EntityDataUriManager Class Reference

Manages URIs for the linked data interface. More...

Public Member Functions

 __construct (Title $interfaceTitle, array $supportedExtensions, array $cachePaths, EntityTitleLookup $entityTitleLookup)
 
 getExtension ( $format)
 
 getFormatName ( $extension)
 
 parseDocName ( $doc)
 Parser for the file-name like document name syntax for specifying an entity data document. More...
 
 getDocName (EntityId $id, $format='')
 Returns the canonical subpage name used to address a given set of entity data. More...
 
 getDocTitle (EntityId $id, $format='')
 Returns a Title representing the given document. More...
 
 getDocUrl (EntityId $id, $format='', $revision=0)
 Returns a Title representing the given document. More...
 
 getCacheableUrls (EntityId $id, int $revision=0)
 Returns a list of all cacheable URLs for all the formats of the given entity. More...
 
 getPotentiallyCachedUrls (EntityId $id, int $revision=0)
 Similar to getCacheableUrls(), but returns internal URLs (to be sent to HtmlCacheUpdater), rather than canonical URLs (against which a request URL may be compared). More...
 

Private Member Functions

 getCacheUrl (string $path, string $entityId, int $revision, string $server)
 Turn a cache path from the config into a full URL. More...
 

Private Attributes

 $interfaceTitle
 
 $supportedExtensions
 
 $cachePaths
 
 $entityTitleLookup
 

Detailed Description

Manages URIs for the linked data interface.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\LinkedData\EntityDataUriManager::__construct ( Title  $interfaceTitle,
array  $supportedExtensions,
array  $cachePaths,
EntityTitleLookup  $entityTitleLookup 
)
Parameters
Title$interfaceTitle
string[]$supportedExtensionsan associative Array mapping canonical format names to file extensions.
string[]$cachePathsList of additional URL paths for which entity data should be cached, with {entity_id} and {revision_id} placeholders.
EntityTitleLookup$entityTitleLookup

Member Function Documentation

◆ getCacheableUrls()

Wikibase\Repo\LinkedData\EntityDataUriManager::getCacheableUrls ( EntityId  $id,
int  $revision = 0 
)

Returns a list of all cacheable URLs for all the formats of the given entity.

Parameters
EntityId$id
int$revisionRevision ID for which to build URLs, or 0 for latest-revision URLs.
Returns
string[] canonical URLs

◆ getCacheUrl()

Wikibase\Repo\LinkedData\EntityDataUriManager::getCacheUrl ( string  $path,
string  $entityId,
int  $revision,
string  $server 
)
private

Turn a cache path from the config into a full URL.

Parameters
string$pathThe path, with {entity_id} and {revision_id} placeholders.
string$entityIdThe entity ID serialization.
int$revisionThe revision ID.
string$serverEither $wgCanonicalServer or $wgInternalServer, depending on what kind of URL you want.
Returns
string A full URL that can be compared against request URLs or sent to HtmlCacheUpdater, depending on $server.

◆ getDocName()

Wikibase\Repo\LinkedData\EntityDataUriManager::getDocName ( EntityId  $id,
  $format = '' 
)

Returns the canonical subpage name used to address a given set of entity data.

Parameters
EntityId$idThe entity
string | null$formatThe (normalized) format name, or ''
Returns
string

◆ getDocTitle()

Wikibase\Repo\LinkedData\EntityDataUriManager::getDocTitle ( EntityId  $id,
  $format = '' 
)

Returns a Title representing the given document.

Parameters
EntityId$idThe entity
string | null$formatThe (normalized) format name, or ''
Returns
Title|null

◆ getDocUrl()

Wikibase\Repo\LinkedData\EntityDataUriManager::getDocUrl ( EntityId  $id,
  $format = '',
  $revision = 0 
)

Returns a Title representing the given document.

Parameters
EntityId$idThe entity
string | null$formatThe (normalized) format name, or ''
int$revision
Returns
string|null

◆ getExtension()

Wikibase\Repo\LinkedData\EntityDataUriManager::getExtension (   $format)
Parameters
string$formata canonical format name
Returns
string|null a file extension (without the leading dot), or null.

◆ getFormatName()

Wikibase\Repo\LinkedData\EntityDataUriManager::getFormatName (   $extension)
Parameters
string$extensionfile extension
Returns
string|null the canonical format name (or null)

◆ getPotentiallyCachedUrls()

Wikibase\Repo\LinkedData\EntityDataUriManager::getPotentiallyCachedUrls ( EntityId  $id,
int  $revision = 0 
)

Similar to getCacheableUrls(), but returns internal URLs (to be sent to HtmlCacheUpdater), rather than canonical URLs (against which a request URL may be compared).

Parameters
EntityId$idas for getCacheableUrls()
int$revisionas for getCacheableUrls()
Returns
string[] internal URLs

◆ parseDocName()

Wikibase\Repo\LinkedData\EntityDataUriManager::parseDocName (   $doc)

Parser for the file-name like document name syntax for specifying an entity data document.

This does not validate or interpret the ID or format, it just splits the string.

Parameters
string$doc
Returns
string[] A 2-element array in the form [ string $id, string $format ]

Member Data Documentation

◆ $cachePaths

Wikibase\Repo\LinkedData\EntityDataUriManager::$cachePaths
private

◆ $entityTitleLookup

Wikibase\Repo\LinkedData\EntityDataUriManager::$entityTitleLookup
private

◆ $interfaceTitle

Wikibase\Repo\LinkedData\EntityDataUriManager::$interfaceTitle
private

◆ $supportedExtensions

Wikibase\Repo\LinkedData\EntityDataUriManager::$supportedExtensions
private

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