function EntityTestHooks::entityInsert

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php \Drupal\entity_test\Hook\EntityTestHooks::entityInsert()

Implements hook_entity_insert().

Attributes

#[Hook('entity_insert')]

File

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

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function entityInsert(EntityInterface $entity) : void {
  if ($entity->getEntityTypeId() == 'entity_test_mulrev' && $entity->label() == 'EntityLoadedRevisionTest') {
    $entity->setNewRevision(FALSE);
    $entity->save();
  }
}

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