function DummyImageFormatter::viewElements

Same name and namespace in other branches
  1. 8.9.x core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyImageFormatter.php \Drupal\image_module_test\Plugin\Field\FieldFormatter\DummyImageFormatter::viewElements()
  2. 10 core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyImageFormatter.php \Drupal\image_module_test\Plugin\Field\FieldFormatter\DummyImageFormatter::viewElements()
  3. 11.x core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyImageFormatter.php \Drupal\image_module_test\Plugin\Field\FieldFormatter\DummyImageFormatter::viewElements()

Builds a renderable array for a field value.

Parameters

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

string $langcode: The language that should be used to render the field.

Return value

array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.

Overrides FormatterInterface::viewElements

File

core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyImageFormatter.php, line 24

Class

DummyImageFormatter
Plugin implementation of the Dummy image formatter.

Namespace

Drupal\image_module_test\Plugin\Field\FieldFormatter

Code

public function viewElements(FieldItemListInterface $items, $langcode) {
    return [
        [
            '#markup' => 'Dummy',
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.