ezcontent-8.x-dev/modules/ezcontent_paragraphs/modules/ezcontent_embed/src/Plugin/Field/FieldFormatter/EmbedFieldFormatter.php

modules/ezcontent_paragraphs/modules/ezcontent_embed/src/Plugin/Field/FieldFormatter/EmbedFieldFormatter.php
<?php

namespace Drupal\ezcontent_embed\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;

/**
 * Plugin implementation of the 'embed' formatter.
 *
 * @FieldFormatter(
 *   id = "ezcontent_embed",
 *   label = @Translation("EZContent Embed"),
 *   field_types = {
 *     "string",
 *     "text",
 *     "text_long",
 *     "text_with_summary"
 *   }
 * )
 */
class EmbedFieldFormatter extends FormatterBase {

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode = NULL) {
    $elements = [];
    foreach ($items as $delta => $item) {
      $elements[$delta] = [
        '#type' => 'inline_template',
        '#template' => $item->value,
      ];
    }
    return $elements;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc