You are here

public function VideoEmbedField::view in Magnific Popup 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/VideoEmbedField.php \Drupal\magnific_popup\Plugin\Field\FieldFormatter\VideoEmbedField::view()

Builds a renderable array for a fully themed field.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.

string $langcode: (optional) The language that should be used to render the field. Defaults to the current content language.

Return value

array A renderable array for a themed field with its label and all its values.

Overrides FormatterBase::view

File

src/Plugin/Field/FieldFormatter/VideoEmbedField.php, line 137

Class

VideoEmbedField
Magnific Popup FieldFormatter for Video Embed Field.

Namespace

Drupal\magnific_popup\Plugin\Field\FieldFormatter

Code

public function view(FieldItemListInterface $items, $langcode = NULL) {
  $elements = parent::view($items, $langcode);
  $gallery_type = $this
    ->getSetting('gallery_type');
  $elements['#attributes']['class'][] = 'mfp-field';
  $elements['#attributes']['class'][] = 'mfp-video-embed-' . Html::cleanCssIdentifier($gallery_type);
  return $elements;
}