You are here

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

Returns count of active paragraph items.

Deleted paragraph items are not deleted immediately, but flagged for removal. This function returns the number of items not flagged for removal.

Parameters

array $items: The array of field items.

4 calls to LayoutParagraphsWidget::activeItemsCount()
LayoutParagraphsWidget::formMultipleElements in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Builds the main widget form array container/wrapper.
LayoutParagraphsWidget::newItemValidate in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
New item validator - checks cardinality.
LayoutParagraphsWidget::removeItemConfirmAjax in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Ajax callback to remove an item - removes item from DOM.
LayoutParagraphsWidget::saveItemAjax in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Ajax callback to return the entire ERL element.

File

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

Class

LayoutParagraphsWidget
Entity Reference with Layout field widget.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldWidget

Code

protected function activeItemsCount(array $items) {
  return array_reduce($items, function ($count, $item) {
    return isset($item['entity']) ? $count + 1 : $count;
  }, 0);
}