You are here

public function EmptyFormattedFieldTest::viewElements in Extra Field 8.2

Same name and namespace in other branches
  1. 8 tests/extra_field_test/src/Plugin/ExtraField/Display/EmptyFormattedFieldTest.php \Drupal\extra_field_test\Plugin\ExtraField\Display\EmptyFormattedFieldTest::viewElements()

Returns the renderable array of the field item(s).

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The field's host entity.

Return value

array A renderable array of field elements. If this contains children, the field output will be rendered as a multiple value field with each child as a field item.

Overrides ExtraFieldDisplayFormattedInterface::viewElements

File

tests/extra_field_test/src/Plugin/ExtraField/Display/EmptyFormattedFieldTest.php, line 42

Class

EmptyFormattedFieldTest
Extra field Display for a field without content.

Namespace

Drupal\extra_field_test\Plugin\ExtraField\Display

Code

public function viewElements(ContentEntityInterface $entity) {
  $elements = [
    '#cache' => [
      'max-age' => 0,
    ],
  ];

  // This field has no content.
  $this->isEmpty = TRUE;
  return $elements;
}