function EntityTestHooks::entityPresave

Implements hook_entity_presave().

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 358

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function entityPresave(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.