You are here

protected function MultipleValuesGenerator::updateFieldIfMoreValuesHaveBeenAdded in Computed Field 3.x

Updates a field's values if some were missing.

Parameters

\Drupal\Core\Field\FieldItemListInterface $field_item_list: The field item list.

array $updated_values: The updated list of values.

Throws

\Drupal\Core\TypedData\Exception\ReadOnlyException

1 call to MultipleValuesGenerator::updateFieldIfMoreValuesHaveBeenAdded()
MultipleValuesGenerator::generateMissingValuesForField in src/MultipleValuesGenerator.php
Generates missing values for a particular computed field.

File

src/MultipleValuesGenerator.php, line 190

Class

MultipleValuesGenerator
Service for generating missing values for multi-valued computed fields.

Namespace

Drupal\computed_field

Code

protected function updateFieldIfMoreValuesHaveBeenAdded(FieldItemListInterface $field_item_list, array $updated_values) {
  if (count($updated_values) > count(array_filter($field_item_list
    ->getValue()))) {
    $field_item_list
      ->setValue($updated_values);
  }
}