Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Section.php

function 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_builder

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal