Invokes a hook on behalf of the entity.
$hook: One of 'presave', 'insert', 'update', 'predelete', or 'delete'.
$entity: The entity object.
protected function invokeHook($hook, EntityInterface $entity) {
// Invoke the hook.
module_invoke_all($this->entityType . '_' . $hook, $entity);
// Invoke the respective entity-level hook.
module_invoke_all('entity_' . $hook, $entity, $this->entityType);
}