You are here

public static function Element::isEmpty in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element::isEmpty()

Indicates whether the given element is empty.

An element that only has #cache set is considered empty, because it will render to the empty string.

Parameters

array $elements: The element.

Return value

bool Whether the given element is empty.

2 calls to Element::isEmpty()
BlockViewBuilder::preRender in core/modules/block/src/BlockViewBuilder.php
#pre_render callback for building a block.
ElementTest::testIsEmpty in core/tests/Drupal/Tests/Core/Render/ElementTest.php
@covers ::isEmpty

File

core/lib/Drupal/Core/Render/Element.php, line 203
Contains \Drupal\Core\Render\Element.

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\Core\Render

Code

public static function isEmpty(array $elements) {
  return empty($elements) || count($elements) === 1 && array_keys($elements) === [
    '#cache',
  ];
}