function rules_entity_presave

Same name in other branches
  1. 7.x-2.x modules/events.inc \rules_entity_presave()

Implements hook_entity_presave().

File

./rules.module, line 133

Code

function rules_entity_presave(EntityInterface $entity) {
    // Only handle content entities and ignore config entities.
    if ($entity instanceof ContentEntityInterface) {
        $entity_type_id = $entity->getEntityTypeId();
        $event = new EntityEvent($entity, [
            $entity_type_id => $entity,
            $entity_type_id . '_unchanged' => $entity->original,
        ]);
        $event_dispatcher = \Drupal::service('event_dispatcher');
        $event_dispatcher->dispatch($event, "rules_entity_presave:{$entity_type_id}");
    }
}