function Element::isEmpty
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element::isEmpty()
- 8.9.x core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element::isEmpty()
- 10 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 or #weight 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.
8 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
File
-
core/
lib/ Drupal/ Core/ Render/ Element.php, line 198
Class
- Element
- Provides helper methods for Drupal render elements.
Namespace
Drupal\Core\RenderCode
public static function isEmpty(array $elements) {
return \array_diff(\array_keys($elements), [
'#cache',
'#weight',
]) === [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.