public download ( string $url, null | string $destinationPath = null, null | integer $timeout = null ) : boolean | string | ||
$url | string | An absolute URL to the marketplace including domain. |
$destinationPath | null | string | |
$timeout | null | integer | Defaults to 60 seconds see {@link self::HTTP_REQUEST_METHOD} |
Résultat | boolean | string | Returns the downloaded data or true if a destination path was given. |
public function download($url, $destinationPath = null, $timeout = null)
{
$method = Http::getTransportMethod();
if (!isset($timeout)) {
$timeout = static::HTTP_REQUEST_TIMEOUT;
}
$post = null;
if ($this->accessToken) {
$post = array('access_token' => $this->accessToken);
}
$file = Http::ensureDestinationDirectoryExists($destinationPath);
$response = Http::sendHttpRequestBy($method, $url, $timeout, $userAgent = null, $destinationPath, $file, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSslCertificate = false, $byteRange = false, $getExtendedInfo = false, $httpMethod = 'POST', $httpUsername = null, $httpPassword = null, $post);
return $response;
}
public function download($pluginOrThemeName) { @ignore_user_abort(true); SettingsServer::setMaxExecutionTime(0); $downloadUrl = $this->getDownloadUrl($pluginOrThemeName); if (empty($downloadUrl)) { return false; } // in the beginning we allowed to specify a download path but this way we make sure security is always taken // care of and we always generate a random download filename. $target = $this->getRandomTmpPluginDownloadFilename(); Filesystem::deleteFileIfExists($target); $success = $this->service->download($downloadUrl, $target, static::HTTP_REQUEST_TIMEOUT); if ($success) { return $target; } return false; }