You are here

public function LayoutParagraphsLayout::getLayoutSection in Layout Paragraphs 2.0.x

Returns a Layout Paragraphs Layout Section for the given paragraph.

If the provided paragraph is not a layout section, returns false.

Parameters

\Drupal\paragraphs\Entity\Paragraph $paragraph: The paragraph.

Return value

\Drupal\layout_paragraphs\LayoutParagraphsSection|false The layout section or false.

1 call to LayoutParagraphsLayout::getLayoutSection()
LayoutParagraphsLayout::deleteComponent in src/LayoutParagraphsLayout.php
Delete a component.

File

src/LayoutParagraphsLayout.php, line 219

Class

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

Namespace

Drupal\layout_paragraphs

Code

public function getLayoutSection(Paragraph $paragraph) {
  if (!LayoutParagraphsSection::isLayoutComponent($paragraph)) {
    return FALSE;
  }
  $uuid = $paragraph
    ->uuid();
  $components = array_filter($this
    ->getComponents(), function ($component) use ($uuid) {
    return $component
      ->getParentUuid() == $uuid;
  });
  return new LayoutParagraphsSection($paragraph, $components);
}