function Section::getComponentsByRegion
Same name in other branches
- 9 core/modules/layout_builder/src/Section.php \Drupal\layout_builder\Section::getComponentsByRegion()
- 8.9.x core/modules/layout_builder/src/Section.php \Drupal\layout_builder\Section::getComponentsByRegion()
- 10 core/modules/layout_builder/src/Section.php \Drupal\layout_builder\Section::getComponentsByRegion()
Gets the components for a specific region.
Parameters
string $region: The region name.
Return value
\Drupal\layout_builder\SectionComponent[] An array of components in the specified region, sorted by weight.
3 calls to Section::getComponentsByRegion()
- Section::getNextHighestWeight in core/
modules/ layout_builder/ src/ Section.php - Returns the next highest weight of the component in a region.
- Section::insertAfterComponent in core/
modules/ layout_builder/ src/ Section.php - Inserts a component after a specified existing component.
- Section::insertComponent in core/
modules/ layout_builder/ src/ Section.php - Inserts a component at a specified delta.
File
-
core/
modules/ layout_builder/ src/ Section.php, line 268
Class
- Section
- Provides a domain object for layout sections.
Namespace
Drupal\layout_builderCode
public function getComponentsByRegion($region) {
$components = array_filter($this->getComponents(), function (SectionComponent $component) use ($region) {
return $component->getRegion() === $region;
});
uasort($components, function (SectionComponent $a, SectionComponent $b) {
return $a->getWeight() <=> $b->getWeight();
});
return $components;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.