CRM_Extension_Downloader
in package
This class handles downloads of remotely-provided extensions
Tags
Table of Contents
Properties
- $container : CRM_Extension_Container_Basic
- $tmpDir : string
- $guzzleClient : Client
- $containerDir : string
- $manager : CRM_Extension_Manager
Methods
- __construct() : mixed
- checkRequirements() : array<string|int, mixed>
- Determine whether downloading is supported.
- download() : bool
- Install or upgrade an extension from a remote URL.
- extractFiles() : string|false
- Extract an extension from a zip file.
- fetch() : bool
- Download the remote zipfile.
- getGuzzleClient() : Client
- setGuzzleClient() : mixed
- validateFiles() : bool
- Validate that $extractedZipPath contains valid for extension $key
Properties
$container
public
CRM_Extension_Container_Basic
$container
The place where downloaded extensions are ultimately stored
$tmpDir
public
string
$tmpDir
Local path to a temporary data directory
$guzzleClient
protected
Client
$guzzleClient
$containerDir
private
string
$containerDir
$manager
private
CRM_Extension_Manager
$manager
Methods
__construct()
public
__construct(CRM_Extension_Manager $manager, string $containerDir, string $tmpDir) : mixed
Parameters
- $manager : CRM_Extension_Manager
- $containerDir : string
-
The place to store downloaded & extracted extensions.
- $tmpDir : string
checkRequirements()
Determine whether downloading is supported.
public
checkRequirements([CRM_Extension_Info $extensionInfo = NULL ]) : array<string|int, mixed>
Parameters
- $extensionInfo : CRM_Extension_Info = NULL
-
Optional info for (updated) extension
Return values
array<string|int, mixed> —list of error messages; empty if OK
download()
Install or upgrade an extension from a remote URL.
public
download(string $key, string $downloadUrl) : bool
Parameters
- $key : string
-
The name of the extension being installed.
- $downloadUrl : string
-
URL of a .zip file.
Tags
Return values
bool —TRUE for success
extractFiles()
Extract an extension from a zip file.
public
extractFiles(string $key, string $zipFile) : string|false
Parameters
- $key : string
-
The name of the extension being installed; this usually matches the basedir in the .zip.
- $zipFile : string
-
The local path to a .zip file.
Return values
string|false —zip file path
fetch()
Download the remote zipfile.
public
fetch(string $remoteFile, string $localFile) : bool
Parameters
- $remoteFile : string
-
URL of a .zip file.
- $localFile : string
-
Path at which to store the .zip file.
Return values
bool —Whether the download was successful.
getGuzzleClient()
public
getGuzzleClient() : Client
Return values
ClientsetGuzzleClient()
public
setGuzzleClient(Client $guzzleClient) : mixed
Parameters
- $guzzleClient : Client
validateFiles()
Validate that $extractedZipPath contains valid for extension $key
public
validateFiles(mixed $key, mixed $extractedZipPath) : bool
Parameters
- $key : mixed
- $extractedZipPath : mixed