Returns a state with all paragraphs closed, if autocollapse is enabled.
array $widget_state: The current widget state.
array The widget state altered by closing all paragraphs.
public static function autocollapse(array $widget_state) {
if ($widget_state['real_item_count'] > 0 && $widget_state['autocollapse'] !== 'none') {
foreach ($widget_state['paragraphs'] as $delta => $value) {
if ($widget_state['paragraphs'][$delta]['mode'] === 'edit') {
$widget_state['paragraphs'][$delta]['mode'] = 'closed';
}
}
}
return $widget_state;
}