function entity_test_entity_presave

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_presave()
  2. 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_presave()
  3. 11.x 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 547

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');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.