You are here

public static function Element::isEmpty in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element::isEmpty()
  2. 9 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, #weight, or #attached 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.

7 calls to Element::isEmpty()
BlockComponentRenderArray::onBuildRender in core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php
Builds render arrays for block plugins and sets it on the event.
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
EntityViewDisplay::buildMultiple in core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
Builds a renderable array for the components of a set of entities.
LayoutBuilderEntityViewDisplay::buildMultiple in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Builds a renderable array for the components of a set of entities.

... See full list

File

core/lib/Drupal/Core/Render/Element.php, line 199

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\Core\Render

Code

public static function isEmpty(array $elements) {
  return \array_diff(\array_keys($elements), [
    '#cache',
    '#weight',
    '#attached',
  ]) === [];
}