You are here

function entity_test_entity_presave in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_presave()

Implements hook_entity_presave().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 460
Test module for the entity API providing several entity types for testing.

Code

function entity_test_entity_presave(EntityInterface $entity) {
  if (isset($GLOBALS['entity_test_throw_exception'])) {
    throw new Exception('Entity presave exception', 1);
  }
  if ($entity
    ->getEntityType()
    ->id() == 'entity_view_display') {
    $entity
      ->setThirdPartySetting('entity_test', 'foo', 'bar');
  }
}