|
Tripal
|
Public Member Functions | |
| __construct (\GuzzleHttp\ClientInterface $httpClient, TripalLogger $logger) | |
| retrieveFileContents (string $url, array $options=[]) | |
Static Public Member Functions | |
| static | create (ContainerInterface $container) |
Protected Member Functions | |
| doRateLimit (float $rate_limit) | |
| doSleep (float $sleep_time) | |
Protected Attributes | |
| $httpClient = NULL | |
| $logger | |
| $last_request_time = NULL | |
The TripalFileLoader class handles copying files from both remote URLs or local file paths, with resiliance against errors.
| Drupal\tripal\Services\TripalFileRetriever::__construct | ( | \GuzzleHttp\ClientInterface | $httpClient, |
| TripalLogger | $logger | ||
| ) |
Constructor
|
static |
{}
|
protected |
Implements a rate limit between successive download requests.
| float | $rate_limit | A number of seconds to wait between successive download requests. If zero, do not wait. |
|
protected |
Sleep for the number of seconds specified by a float.
Since usleep() may not support > 1 second, this uses time_nanosleep().
| float | $sleep_time | A positive real number specifying some amount of time to sleep. |
| Drupal\tripal\Services\TripalFileRetriever::retrieveFileContents | ( | string | $url, |
| array | $options = [] |
||
| ) |
Download the contents of a remote or local file from a specified URL.
The contents of the file are returned as a string for both remote and local files.
NOTE: This method will retry if it is unable to download the file from an accessible URL. This is controlled via the 'retries' and 'retry_delay' options. If the URL provided is inaccessible this triggers the 'rate_limit' option.
| string | $url | The address of the file to download |
| array | $options | Valid keys:
|
|
protected |
The Drupal HTTP service (i.e. guzzle)
|
protected |
A logger object.