function field_defaults_entity_presave in Field Defaults 8
Same name and namespace in other branches
- 7.2 field_defaults.module \field_defaults_entity_presave()
Implements hook_entity_presave().
File
- ./
field_defaults.module, line 14 - Allows updating existing content with default values.
Code
function field_defaults_entity_presave(EntityInterface $entity) {
// If this entity is not being saved through the field_defaults module, leave the changed date alone.
if (empty($entity->batch_field_defaults)) {
return;
}
unset($entity->batch_field_defaults);
$config = \Drupal::config('field_defaults.configuration');
$changeDate = $config
->get('update_date');
if ($changeDate == '1' && isset($entity->original->changed)) {
$entity->changed = $entity->original->changed;
}
}