Removes default behavior form values before storing the user-set ones.
Default implementation considers a value to be default if and only if it is an empty value. Behavior plugins that do not consider all empty values to be default should override this method or \Drupal\paragraphs\ParagraphsBehaviorBase::submitBehaviorForm.
\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph.
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array An associative array of values submitted to the form with all empty leaves removed. Subarrays that only contain empty leaves are also removed.
protected function filterBehaviorFormSubmitValues(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
// Keeps removing empty leaves, until there are none left. So if a subarray
// only contains empty leaves, that subarray itself will be removed.
$new_array = $form_state
->getValues();
do {
$old_array = $new_array;
$new_array = NestedArray::filter($old_array);
} while ($new_array !== $old_array);
return $new_array;
}