You are here

protected function LayoutParagraphsWidget::removeChildren in Layout Paragraphs 1.0.x

Recursively remove decendants from list of items.

Parameters

array $items: The entire list of items.

string $uuid: The parent/ancestor uuid.

1 call to LayoutParagraphsWidget::removeChildren()
LayoutParagraphsWidget::removeItemConfirmSubmit in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Form submit handler - removes/deletes an item.

File

src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php, line 2095

Class

LayoutParagraphsWidget
Entity Reference with Layout field widget.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldWidget

Code

protected function removeChildren(array &$items, string $uuid) {
  foreach ($items as $index => $item) {
    if (isset($item['entity'])) {

      /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
      $paragraph = $item['entity'];
      $layout_settings = $this
        ->getLayoutSettings($paragraph);
      if ($layout_settings['parent_uuid'] == $uuid) {
        unset($items[$index]['entity']);
        $this
          ->removeChildren($items, $paragraph
          ->uuid());
      }
    }
  }
}