class ResourceFetcher in Media Migration 8
Simple oEmbed resource fetcher replacement for remote media migration tests.
Hierarchy
- class \Drupal\media\OEmbed\ResourceFetcher implements ResourceFetcherInterface uses UseCacheBackendTrait
- class \Drupal\media_migration_test_oembed\ResourceFetcher
Expanded class hierarchy of ResourceFetcher
File
- tests/
modules/ media_migration_test_oembed/ src/ ResourceFetcher.php, line 13
Namespace
Drupal\media_migration_test_oembedView source
class ResourceFetcher extends BaseResourceFetcher {
/**
* {@inheritdoc}
*/
public function fetchResource($oembed_url) {
$hashed = Crypt::hashBase64($oembed_url);
$resource_array = \Drupal::state()
->get("media_migration_test_oembed.{$hashed}", [
'type' => 'video',
'html' => urlencode($oembed_url),
'width' => 320,
'height' => 180,
]);
$type = $resource_array['type'];
unset($resource_array['type']);
try {
$resource = call_user_func_array([
Resource::class,
$type,
], $resource_array);
} catch (\Exception $e) {
throw new ResourceException(sprintf('Test media oembed resource %s cannot be fetched', $oembed_url), $oembed_url);
}
assert($resource instanceof Resource);
return $resource;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ResourceFetcher:: |
protected | property | The HTTP client. | |
ResourceFetcher:: |
protected | property | The oEmbed provider repository service. | |
ResourceFetcher:: |
protected | function | Creates a Resource object from raw resource data. | |
ResourceFetcher:: |
public | function |
Fetches an oEmbed resource. Overrides ResourceFetcher:: |
|
ResourceFetcher:: |
protected | function | Parses XML resource data. | |
ResourceFetcher:: |
public | function | Constructs a ResourceFetcher object. | |
UseCacheBackendTrait:: |
protected | property | Cache backend instance. | |
UseCacheBackendTrait:: |
protected | property | Flag whether caches should be used or skipped. | |
UseCacheBackendTrait:: |
protected | function | Fetches from the cache backend, respecting the use caches flag. | 1 |
UseCacheBackendTrait:: |
protected | function | Stores data in the persistent cache, respecting the use caches flag. |