Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#3833 Update CRM_Extension_Downloader to not use dynamic properties #24438

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions CRM/Extension/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,31 @@
class CRM_Extension_Downloader {

/**
* @var GuzzleHttp\Client
* @var CRM_Extension_Manager
*/
protected $guzzleClient;
private $manager;

/**
* @return \GuzzleHttp\Client
* @var string
*/
public function getGuzzleClient(): \GuzzleHttp\Client {
return $this->guzzleClient ?? new \GuzzleHttp\Client();
}
private $containerDir;

/**
* @param \GuzzleHttp\Client $guzzleClient
* @var string
* Local path to a temporary data directory
*/
public function setGuzzleClient(\GuzzleHttp\Client $guzzleClient) {
$this->guzzleClient = $guzzleClient;
}
public $tmpDir;

/**
* @var CRM_Extension_Container_Basic
* The place where downloaded extensions are ultimately stored
* @var GuzzleHttp\Client
*/
public $container;
protected $guzzleClient;

/**
* @var string
* Local path to a temporary data directory
* @var CRM_Extension_Container_Basic
* The place where downloaded extensions are ultimately stored
*/
public $tmpDir;
public $container;

/**
* @param CRM_Extension_Manager $manager
Expand All @@ -60,6 +56,20 @@ public function __construct(CRM_Extension_Manager $manager, $containerDir, $tmpD
$this->tmpDir = $tmpDir;
}

/**
* @return \GuzzleHttp\Client
*/
public function getGuzzleClient(): \GuzzleHttp\Client {
return $this->guzzleClient ?? new \GuzzleHttp\Client();
}

/**
* @param \GuzzleHttp\Client $guzzleClient
*/
public function setGuzzleClient(\GuzzleHttp\Client $guzzleClient) {
$this->guzzleClient = $guzzleClient;
}

/**
* Determine whether downloading is supported.
*
Expand Down Expand Up @@ -121,7 +131,6 @@ public function checkRequirements($extensionInfo = NULL) {
*/
public function download($key, $downloadUrl) {
$filename = $this->tmpDir . DIRECTORY_SEPARATOR . $key . '.zip';
$destDir = $this->containerDir . DIRECTORY_SEPARATOR . $key;

if (!$downloadUrl) {
throw new CRM_Extension_Exception(ts('Cannot install this extension - downloadUrl is not set!'));
Expand Down