TerExtensionRemote

class \TYPO3\CMS\Extensionmanager\Remote\TerExtensionRemote

Implements
ExtensionDownloaderRemoteInterface, ListableRemoteInterface

Class for downloading extension archives from extensions.typo3.org and validating the results.

This also includes the ListableRemoteInterface, which means it downloads extensions.xml.gz files and can import it in the database.

This is the only dependency for the concrete TER implementation on extensions.typo3.org and encapsulates the definition where an extension is located in TER.

Not responsible for:

  • installing / activating an extension

Table of Contents

Interfaces

ExtensionDownloaderRemoteInterface
API for downloading packages from a remote server and validating the downloaded results.
ListableRemoteInterface
API for downloading a list of available packages from a server.

Constants

SHA256_PREFIX  : string = 'sha256:'

Properties

$identifier  : string
$localExtensionListCacheFile  : string
$remoteBase  : string

Methods

__construct()  : mixed
downloadExtension()  : void
Downloads a single extension and extracts it into a target location folder.
getAvailablePackages()  : void
Download the xml.gz file, and extract it into the database.
getIdentifier()  : string
Returns the remote identifier
getLastUpdate()  : DateTimeInterface
Get the time when the remote was updated the last time.
needsUpdate()  : bool
Checks whether the remote is outdated and should fetch latest updates.
buildRemotePath()  : string
decodeExchangeData()  : array
Decodes extension array from t3x file contents.
downloadExchangeFile()  : void
downloadFile()  : ResponseInterface
Internal method
downloadZipArchive()  : void
extractArtifactSha256()  : string|null
Returns the bare hash of a "sha256:<hash>" verification hash, and null for anything else - which is what makes an extension list without artifact hashes fall back to the t3x file.
fetchPackageList()  : void
Downloads the extensions.xml.gz and imports it into the database.
isDownloadedExtensionListUpToDate()  : bool
TER provides an extensions.md5 which contains the hashsum of the current remote extensions.gz file.
isDownloadedPackageValid()  : bool
Validates the integrity of the contents of a downloaded file.

Constants

SHA256_PREFIX

protected string SHA256_PREFIX = 'sha256:'

Properties

$localExtensionListCacheFile

protected string $localExtensionListCacheFile

$remoteBase

protected string $remoteBase = 'https://extensions.typo3.org/fileadmin/ter/'

Methods

__construct()

public __construct(string $identifier[, array $options = [] ]) : mixed

Parameters

$identifier : string
$options : array = []

downloadExtension()

Downloads a single extension and extracts it into a target location folder.

public downloadExtension(string $extensionKey, string $version, FileHandlingUtility $fileHandler[, string|null $verificationHash = null ][, string $pathType = 'Local' ]) : void

The zip archive is preferred whenever the extension list provides a SHA-256 hash for it, since it is the artifact the extension author uploaded. Without such a hash the legacy t3x file is fetched and the extension is rebuilt from its serialized contents.

Parameters

$extensionKey : string

a lower-cased extension key

$version : string

the version to be fetched e.g. 1.5.2

$fileHandler : FileHandlingUtility

the file handler which deals with unpacking the files

$verificationHash : string|null = null

either "sha256:" for the zip archive, or a plain MD5 hash of the t3x file

$pathType : string = 'Local'

either "Local", "System" or "Global"

Tags

throws
DownloadFailedException
throws
VerificationFailedException

getAvailablePackages()

Download the xml.gz file, and extract it into the database.

public getAvailablePackages([bool $force = false ]) : void

Parameters

$force : bool = false

getIdentifier()

Returns the remote identifier

public getIdentifier() : string

Return values

string

getLastUpdate()

Get the time when the remote was updated the last time.

public getLastUpdate() : DateTimeInterface

Return values

DateTimeInterface

needsUpdate()

Checks whether the remote is outdated and should fetch latest updates.

public needsUpdate() : bool

Return values

bool

buildRemotePath()

protected buildRemotePath(string $extensionKey, string $version, string $fileExtension) : string

Parameters

$extensionKey : string
$version : string
$fileExtension : string

Return values

string

decodeExchangeData()

Decodes extension array from t3x file contents.

protected decodeExchangeData(string $stream) : array

This kind of data is when an extension is uploaded to TER

Parameters

$stream : string

Data stream

Tags

throws
VerificationFailedException

Return values

array —

Array with result on success, otherwise an error string.

downloadFile()

Internal method

protected downloadFile(string $remotePath) : ResponseInterface

Parameters

$remotePath : string

Tags

throws
DownloadFailedException

Return values

ResponseInterface

extractArtifactSha256()

Returns the bare hash of a "sha256:<hash>" verification hash, and null for anything else - which is what makes an extension list without artifact hashes fall back to the t3x file.

protected extractArtifactSha256(string|null $verificationHash) : string|null

Parameters

$verificationHash : string|null

Return values

string|null

fetchPackageList()

Downloads the extensions.xml.gz and imports it into the database.

protected fetchPackageList() : void

isDownloadedExtensionListUpToDate()

TER provides an extensions.md5 which contains the hashsum of the current remote extensions.gz file.

protected isDownloadedExtensionListUpToDate() : bool

Let's check if this is the same, if so, it is not needed to download a new extensions.gz.

Return values

bool

isDownloadedPackageValid()

Validates the integrity of the contents of a downloaded file.

protected isDownloadedPackageValid(string $expectedHash, string $fileContents) : bool

Parameters

$expectedHash : string
$fileContents : string

Return values

bool
On this page