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 : mixed = '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
mixed
SHA256_PREFIX
= 'sha256:'
Properties
$identifier
protected
string
$identifier
$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
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
stringgetLastUpdate()
Get the time when the remote was updated the last time.
public
getLastUpdate() : DateTimeInterface
Return values
DateTimeInterfaceneedsUpdate()
Checks whether the remote is outdated and should fetch latest updates.
public
needsUpdate() : bool
Return values
boolbuildRemotePath()
protected
buildRemotePath(string $extensionKey, string $version, string $fileExtension) : string
Parameters
- $extensionKey : string
- $version : string
- $fileExtension : string
Return values
stringdecodeExchangeData()
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
Return values
array —Array with result on success, otherwise an error string.
downloadExchangeFile()
protected
downloadExchangeFile(string $extensionKey, string $version, FileHandlingUtility $fileHandler, string|null $verificationHash) : void
Parameters
- $extensionKey : string
- $version : string
- $fileHandler : FileHandlingUtility
- $verificationHash : string|null
Tags
downloadFile()
Internal method
protected
downloadFile(string $remotePath) : ResponseInterface
Parameters
- $remotePath : string
Tags
Return values
ResponseInterfacedownloadZipArchive()
protected
downloadZipArchive(string $extensionKey, string $version, FileHandlingUtility $fileHandler, string $expectedSha256) : void
Parameters
- $extensionKey : string
- $version : string
- $fileHandler : FileHandlingUtility
- $expectedSha256 : string
Tags
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|nullfetchPackageList()
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
boolisDownloadedPackageValid()
Validates the integrity of the contents of a downloaded file.
protected
isDownloadedPackageValid(string $expectedHash, string $fileContents) : bool
Parameters
- $expectedHash : string
- $fileContents : string