public static function Element::isEmpty in Drupal 9
Same name and namespace in other branches
- 8 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.
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.
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 empty($elements) || count($elements) === 1 && array_keys($elements) === [
'#cache',
];
}