protected function Resource::__construct in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::__construct()
- 10 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::__construct()
Resource constructor.
Parameters
\Drupal\media\OEmbed\Provider $provider: (optional) The resource provider.
string $title: (optional) A text title, describing the resource.
string $author_name: (optional) The name of the author/owner of the resource.
string $author_url: (optional) A URL for the author/owner of the resource.
int $cache_age: (optional) The suggested cache lifetime for this resource, in seconds.
string $thumbnail_url: (optional) A URL to a thumbnail image representing the resource. If this parameter is present, $thumbnail_width and $thumbnail_height must also be present.
int $thumbnail_width: (optional) The width of the thumbnail, in pixels. If this parameter is present, $thumbnail_url and $thumbnail_height must also be present.
int $thumbnail_height: (optional) The height of the thumbnail, in pixels. If this parameter is present, $thumbnail_url and $thumbnail_width must also be present.
File
- core/
modules/ media/ src/ OEmbed/ Resource.php, line 176
Class
- Resource
- Value object representing an oEmbed resource.
Namespace
Drupal\media\OEmbedCode
protected function __construct(Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) {
$this->provider = $provider;
$this->title = $title;
$this->authorName = $author_name;
$this->authorUrl = $author_url;
if (isset($cache_age) && is_numeric($cache_age)) {
// If the cache age is too big, it can overflow the 'expire' column of
// database cache backends, causing SQL exceptions. To prevent that,
// arbitrarily limit the cache age to 5 years. That should be enough.
$this->cacheMaxAge = Cache::mergeMaxAges((int) $cache_age, 157680000);
}
if ($thumbnail_url) {
$this->thumbnailUrl = $thumbnail_url;
$this
->setThumbnailDimensions($thumbnail_width, $thumbnail_height);
}
}