public static function StreamWrapperConfiguration::fromConfig in AmazonS3 7.2
Generate a configuration object from an array.
Parameters
array $config: (optional) An array of configuration data. Each key is a lower-cased string corresponding with a set method.
array $defaults: (optional) Override the default settings.
array $required: (optional) Override the required settings.
Return value
StreamWrapperConfiguration The stream wrapper configuration.
1 call to StreamWrapperConfiguration::fromConfig()
- StreamWrapperConfiguration::fromDrupalVariables in src/
StreamWrapperConfiguration.php - Set the stream wrapper configuration using Drupal variables.
File
- src/
StreamWrapperConfiguration.php, line 44
Class
- StreamWrapperConfiguration
- Class to manage S3 stream wrapper configuration.
Namespace
Drupal\amazons3Code
public static function fromConfig(array $config = array(), array $defaults = array(), array $required = array()) {
if (empty($defaults)) {
$defaults = self::defaults();
}
if (empty($required)) {
$required = self::required();
}
$data = $config + $defaults;
if ($data['caching']) {
$required[] = 'expiration';
}
if ($missing = array_diff($required, array_keys(array_filter($data, function ($item) {
return !is_null($item) && $item !== '';
})))) {
throw new \InvalidArgumentException('Config is missing the following keys: ' . implode(', ', $missing));
}
if (!$data['domain']) {
$data['domain'] = self::getS3Domain($data['bucket']);
}
return new static($data);
}