Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291388

Add hook_entity_postsave hook

$
0
0

Problem/Motivation

In order to intercept an entity after it has saved, both hook_entity_insert and hook_entity_update must be implemented.

Proposed resolution

Add hook_entity_postsave. Detect if entity is new or being updated using entity API: $entity->isNew()

Remaining tasks

User interface changes

None

API changes

Deprecate hook_entity_[type_]insert and hook_entity_[type_]update.

Data model changes

Original report by ivanjaros

We already have a hook_entity_presave hook so why don't we also have hook_entity_postsave?
In current state if I want to run some logic after the entity hase been saved, and I don't care if it is/was new or already existing entity, I have to implement TWO hooks instead of just one: hook_entity_insert AND hook_entity_update.


Viewing all articles
Browse latest Browse all 291388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>