function ResponsiveImageTestFormatter::viewElements

Same name in other branches
  1. 8.9.x core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php \Drupal\responsive_image_test_module\Plugin\Field\FieldFormatter\ResponsiveImageTestFormatter::viewElements()
  2. 10 core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php \Drupal\responsive_image_test_module\Plugin\Field\FieldFormatter\ResponsiveImageTestFormatter::viewElements()
  3. 11.x core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php \Drupal\responsive_image_test_module\Plugin\Field\FieldFormatter\ResponsiveImageTestFormatter::viewElements()

Overrides ResponsiveImageFormatter::viewElements

File

core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php, line 24

Class

ResponsiveImageTestFormatter
Plugin to test responsive image formatter.

Namespace

Drupal\responsive_image_test_module\Plugin\Field\FieldFormatter

Code

public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = parent::viewElements($items, $langcode);
    // Unset #item_attributes to test that the theme function can handle that.
    foreach ($elements as &$element) {
        if (isset($element['#item_attributes'])) {
            unset($element['#item_attributes']);
        }
    }
    return $elements;
}

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