You are here

function auto_entityqueue_entity_insert in Auto Entityqueue 8

Same name and namespace in other branches
  1. 7 auto_entityqueue.module \auto_entityqueue_entity_insert()

Implements hook_entity_insert().

File

./auto_entityqueue.module, line 54
Handles automatically adding entities to entityqueues.

Code

function auto_entityqueue_entity_insert(EntityInterface $entity) {
  $type = $entity
    ->getEntityTypeId();
  $bundle = $entity
    ->bundle();

  // Get queues for this entity type and bundle combo.
  $queues = auto_entityqueue_get_queues_by_type_and_bundle($type, $bundle);
  if (count($queues)) {

    // Add the entity to each queues returned.
    foreach ($queues as $queue) {
      auto_entityqueue_add_entity_to_queue($entity, $queue);
    }
  }
}