Skip to content
Snippets Groups Projects
Commit 28e51db6 authored by Alen Pagac's avatar Alen Pagac
Browse files

#3065666: Fixed video PG processor to enable class inheriting.

parent 997e862f
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,13 @@ class ParagraphVideoProcessor implements CustomElementProcessorInterface {
*/
protected $providerManager;
/**
* Video embed provider.
*
* @var \Drupal\media\OEmbed\Provider $provider
*/
protected $provider;
/**
* Constructs the renderer.
*
......@@ -56,11 +63,11 @@ class ParagraphVideoProcessor implements CustomElementProcessorInterface {
/** @var \Drupal\media_entity\Entity\Media $media_entity */
$media_entity = $paragraph->field_video->entity;
$provider = $this->providerManager->loadProviderFromInput($media_entity->field_media_video_embed_field->value);
if (!$provider) {
$this->provider = $this->providerManager->loadProviderFromInput($media_entity->field_media_video_embed_field->value);
if (!$this->provider) {
return;
}
$embed_code = $provider->renderEmbedCode('0', '0', FALSE);
$embed_code = $this->provider->renderEmbedCode('0', '0', FALSE);
$video_element = new CustomElement();
$video_element->addCacheableDependency($media_entity);
......@@ -68,7 +75,7 @@ class ParagraphVideoProcessor implements CustomElementProcessorInterface {
$video_element->setAttributes(['src' => $embed_code['#url']]);
$element->setSlotFromCustomElement('video', $video_element);
$element->setSlot('thumbnail', '', 'img', ['src' => $provider->getRemoteThumbnailUrl()]);
$element->setSlot('thumbnail', '', 'img', ['src' => $this->provider->getRemoteThumbnailUrl()]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment