TerApiClient

class \TYPO3\CMS\Extensionmanager\Remote\TerApiClient

Extends
AbstractJsonApiClient

Connector to the TER REST API at https://extensions.typo3.org/api/v1.

Reads the catalogue live, without the local mirror of extensions.xml.gz. Downloading is not its business: an extension is fetched from the archive TER stores for it, which TerExtensionRemote already does.

Responses are cached for a short period, so paginating and navigating back and forth does not hammer TER, and a rate limit is not spent on repeating the same question; see AbstractJsonApiClient.

Table of Contents

Constants

UNAVAILABLE_CACHE_IDENTIFIER  : mixed = 'ter_api_unavailable'
UNAVAILABLE_LIFETIME  : mixed = 300

Properties

$cache  : FrontendInterface
$requestFactory  : RequestFactory
$typo3Version  : Typo3Version

Methods

__construct()  : mixed
getExtension()  : TerExtension|null
getVersions()  : array
query()  : TerExtensionListResult
getRequestOptions()  : array<string, mixed>
Error statuses are inspected here rather than thrown by the HTTP client, since a 404 is an answer. The timeouts are deliberately short: the imported list answers when TER is slow, which beats leaving the module hanging.
isSuccessfulResponse()  : bool
request()  : array|null
requestJson()  : array|null
unwrapEnvelope()  : array|null
Unwraps the single-element outer array the API uses to envelope single resources, e.g. [{...}] becomes {...}. Recognized by the presence of the given discriminator key on the inner element.

Constants

UNAVAILABLE_CACHE_IDENTIFIER

protected mixed UNAVAILABLE_CACHE_IDENTIFIER = 'ter_api_unavailable'

UNAVAILABLE_LIFETIME

protected mixed UNAVAILABLE_LIFETIME = 300

Properties

Methods

getVersions()

public getVersions(string $extensionKey) : array

Parameters

$extensionKey : string

Return values

array

query()

public query(string $search, int $typo3MajorVersion[, int $page = 1 ][, int $perPage = 20 ][, string|null $category = null ][, string|null $username = null ]) : TerExtensionListResult

Parameters

$search : string
$typo3MajorVersion : int
$page : int = 1
$perPage : int = 20
$category : string|null = null
$username : string|null = null

Return values

TerExtensionListResult

getRequestOptions()

Error statuses are inspected here rather than thrown by the HTTP client, since a 404 is an answer. The timeouts are deliberately short: the imported list answers when TER is slow, which beats leaving the module hanging.

protected getRequestOptions() : array<string, mixed>

Return values

array<string, mixed>

isSuccessfulResponse()

protected isSuccessfulResponse(ResponseInterface $response) : bool

Parameters

$response : ResponseInterface

Return values

bool

request()

protected request(string $path[, array<string, mixed> $query = [] ]) : array|null

Parameters

$path : string
$query : array<string, mixed> = []

Tags

throws
ApiRequestFailedException

when the remote could not answer at all

Return values

array|null —

null when the remote does not know the resource

requestJson()

protected requestJson(string $url) : array|null

Parameters

$url : string

Tags

throws
ApiRequestFailedException

when the remote could not answer at all

Return values

array|null —

null when the remote does not know the resource

unwrapEnvelope()

Unwraps the single-element outer array the API uses to envelope single resources, e.g. [{...}] becomes {...}. Recognized by the presence of the given discriminator key on the inner element.

protected unwrapEnvelope(array|null $data, string $discriminatorKey) : array|null

Parameters

$data : array|null
$discriminatorKey : string

Return values

array|null
On this page