You are here

protected function EntityFormField::entityShouldBeSaved in Views Entity Form Field 8

Determines if an entity should be saved.

Parameters

EntityInterface $entity: The possibly modified entity in question.

EntityInterface $original_entity: The original unmodified entity.

Return value

bool TRUE if the entity should be saved; FALSE otherwise.

1 call to EntityFormField::entityShouldBeSaved()
EntityFormField::saveEntities in src/Plugin/views/field/EntityFormField.php
Save the view's entities.

File

src/Plugin/views/field/EntityFormField.php, line 656

Class

EntityFormField
Defines a views form element for an entity field widget.

Namespace

Drupal\views_entity_form_field\Plugin\views\field

Code

protected function entityShouldBeSaved(EntityInterface $entity, EntityInterface $original_entity) {
  $save_entity = FALSE;
  foreach ($entity as $field_name => $new_field) {
    $original_field = $original_entity
      ->get($field_name);
    if (!$new_field
      ->equals($original_field)) {
      $save_entity = TRUE;
      break;
    }
  }
  return $save_entity;
}