public static function S3Url::factory in AmazonS3 7.2
Overrides factory() to support bucket configs.
Parameters
string $url: Full URL used to create a Url object.
\Drupal\amazons3\StreamWrapperConfiguration $config: (optional) Configuration to associate with this URL.
Return value
static An S3Url.
Throws
\InvalidArgumentException Thrown when $url cannot be parsed by parse_url().
7 calls to S3Url::factory()
- amazons3_file_entity_upload_destination_uri_alter in ./
amazons3.module - Implements hook_file_entity_upload_destination_uri_alter().
- amazons3_file_stream_wrapper_uri_normalize_alter in ./
amazons3.module - Implements hook_file_stream_wrapper_uri_normalize_alter().
- amazons3_image_style_path_alter in ./
amazons3.module - Implements hook_image_style_path_alter().
- S3UrlTest::testFactory in tests/
S3UrlTest.php - @covers Drupal\amazons3\S3Url::factory
- S3UrlTest::testFactoryInvalidUrl in tests/
S3UrlTest.php - @expectedException \InvalidArgumentException @covers Drupal\amazons3\S3Url::factory
File
- src/
S3Url.php, line 122
Class
- S3Url
- Represents an s3:// stream URL.
Namespace
Drupal\amazons3Code
public static function factory($url, StreamWrapperConfiguration $config = null) {
!$config ? $bucket = null : ($bucket = $config
->getBucket());
$defaults = array(
'scheme' => 's3',
'host' => $bucket,
'path' => null,
'port' => null,
'query' => null,
'user' => null,
'pass' => null,
'fragment' => null,
);
if (false === ($parts = parse_url($url))) {
throw new \InvalidArgumentException('Was unable to parse malformed url: ' . $url);
}
$parts += $defaults;
return new static($parts['host'], substr($parts['path'], 1));
}