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

Breadcrumb

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

function Section::insertAfterComponent

Inserts a component after a specified existing component.

Parameters

string $preceding_uuid: The UUID of the existing component to insert after.

\Drupal\layout_builder\SectionComponent $component: The component being inserted.

Return value

$this

Throws

\InvalidArgumentException Thrown when the expected UUID does not exist.

File

core/modules/layout_builder/src/Section.php, line 291

Class

Section
Provides a domain object for layout sections.

Namespace

Drupal\layout_builder

Code

public function insertAfterComponent($preceding_uuid, SectionComponent $component) {
    // Find the delta of the specified UUID.
    $uuids = array_keys($this->getComponentsByRegion($component->getRegion()));
    $delta = array_search($preceding_uuid, $uuids, TRUE);
    if ($delta === FALSE) {
        throw new \InvalidArgumentException(sprintf('Invalid preceding UUID "%s"', $preceding_uuid));
    }
    return $this->insertComponent($delta + 1, $component);
}

API Navigation

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