You are here

public function GutenbergTextFormatter::view in Gutenberg 8.2

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/GutenbergTextFormatter.php, line 115

Class

GutenbergTextFormatter
Plugin implementation of the 'gutenberg_text' formatter.

Namespace

Drupal\gutenberg\Plugin\Field\FieldFormatter

Code

public function view(FieldItemListInterface $items, $langcode = NULL) {
  $elements = parent::view($items, $langcode);
  if (isset($elements['#theme']) && $this
    ->getSetting('content_only')) {

    // Render using the Gutenberg text field theme.
    $elements['#theme'] = 'field_gutenberg_text';
  }
  return $elements;
}