function rules_entity_insert

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

Implements hook_entity_insert().

File

./rules.module, line 162

Code

function rules_entity_insert(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,
        ]);
        $event_dispatcher = \Drupal::service('event_dispatcher');
        $event_dispatcher->dispatch($event, "rules_entity_insert:{$entity_type_id}");
    }
}