You are here

protected function LayoutParagraphsLayout::getComponentDeltaByUuid in Layout Paragraphs 2.0.x

Searchs for a component by its uuid and returns its delta.

Parameters

string $uuid: The uuid to search for.

Return value

int The component's delta, or -1 if no match.

3 calls to LayoutParagraphsLayout::getComponentDeltaByUuid()
LayoutParagraphsLayout::deleteComponent in src/LayoutParagraphsLayout.php
Delete a component.
LayoutParagraphsLayout::insertSiblingComponent in src/LayoutParagraphsLayout.php
Insert an new item adjacent to $sibling.
LayoutParagraphsLayout::setComponent in src/LayoutParagraphsLayout.php
Sets a layout component.

File

src/LayoutParagraphsLayout.php, line 492

Class

LayoutParagraphsLayout
Provides a domain object for a complete Layout Paragraphs Layout.

Namespace

Drupal\layout_paragraphs

Code

protected function getComponentDeltaByUuid(string $uuid) {
  foreach ($this->paragraphsReferenceField as $key => $item) {
    if (isset($item->entity) && $item->entity
      ->uuid() == $uuid) {
      return $key;
    }
  }
  return -1;
}