You are here

function entityqueue_smartqueue_entity_update in Entityqueue 8

Implements hook_entity_update().

File

modules/entityqueue_smartqueue/entityqueue_smartqueue.module, line 92
Provides automated subqueues for each entity of a given entity type.

Code

function entityqueue_smartqueue_entity_update(EntityInterface $entity) {
  $queues = _entityqueue_smartqueue_get_queues($entity
    ->getEntityTypeId());
  foreach ($queues as $queue) {

    // Check if the entity that got updated is of the relevant bundle.
    if (!in_array($entity
      ->bundle(), $queue
      ->getHandlerConfiguration()['bundles'], TRUE)) {
      continue;
    }
    if ($subqueue = EntitySubqueue::load($queue
      ->id() . '__' . $entity
      ->id())) {
      $subqueue
        ->set('title', $entity
        ->label());
      $subqueue
        ->save();
    }
  }
}