protected function ParagraphsWidget::getNumberOfParagraphsInMode in Paragraphs 8
Counts the number of paragraphs in a certain mode in a form substructure.
Parameters
array $widget_state: The widget state for the form substructure containing information about the paragraphs within.
string $mode: The mode to look for.
Return value
int The number of paragraphs is the given mode.
File
- src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php, line 2483
Class
- ParagraphsWidget
- Plugin implementation of the 'entity_reference_revisions paragraphs' widget.
Namespace
Drupal\paragraphs\Plugin\Field\FieldWidgetCode
protected function getNumberOfParagraphsInMode(array $widget_state, $mode) {
if (!isset($widget_state['paragraphs'])) {
return 0;
}
$paragraphs_count = 0;
foreach ($widget_state['paragraphs'] as $paragraph) {
if ($paragraph['mode'] == $mode) {
$paragraphs_count++;
}
}
return $paragraphs_count;
}