public function StreamWrapper::__construct in AmazonS3 7.2
Construct a new stream wrapper.
Parameters
\Drupal\amazons3\StreamWrapperConfiguration $config: (optional) A specific configuration to use for this wrapper.
File
- src/
StreamWrapper.php, line 109 - Drupal stream wrapper implementation for Amazon S3
Class
- StreamWrapper
- @file Drupal stream wrapper implementation for Amazon S3
Namespace
Drupal\amazons3Code
public function __construct(StreamWrapperConfiguration $config = NULL) {
if (!$config) {
if (static::$defaultConfig) {
$config = static::$defaultConfig;
}
else {
// @codeCoverageIgnoreStart
$config = StreamWrapperConfiguration::fromDrupalVariables();
// @codeCoverageIgnoreEnd
}
}
$this->config = $config;
if (!$this
->getClient()) {
/** @var S3Client $name */
$name = static::$s3ClientClass;
$this
->setClient($name::factory(array(
'region' => $this->config
->getRegion(),
)));
}
if ($this->config
->isCaching() && !static::$cache) {
static::attachCache(new DoctrineCacheAdapter(new ChainCache([
new ArrayCache(),
new Cache(),
])), $this->config
->getCacheLifetime());
}
}