You are here

public function MultipleValuesGenerator::generateMissingValues in Computed Field 3.x

Generates missing computed-field values in multi-valued computed fields.

Throws

\Exception If the entity is missing.

File

src/MultipleValuesGenerator.php, line 100

Class

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

Namespace

Drupal\computed_field

Code

public function generateMissingValues() {
  $entity = $this
    ->getEntity();
  if (!$entity instanceof FieldableEntityInterface) {
    return;
  }
  $field_definitions = $this->entityFieldManager
    ->getFieldDefinitions($entity
    ->getEntityTypeId(), $entity
    ->bundle());
  foreach ($field_definitions as $field_id => $field_definition) {
    if ($this
      ->fieldIsNotComputed($field_definition)) {
      continue;
    }
    $this
      ->generateMissingValuesForField($field_id, $field_definition);
  }
}