You are here

function media_acquiadam_refresh_asset_sync_queue in Media: Acquia DAM 8

Adds media items to the asset sync queue for later processing.

Adds all existing active media entities to the queue.

Return value

int The number of items currently in the queue.

1 call to media_acquiadam_refresh_asset_sync_queue()
media_acquiadam_cron in ./media_acquiadam.module
Implements hook_cron().

File

./media_acquiadam.module, line 294
Integrates Drupal with Acquia DAM.

Code

function media_acquiadam_refresh_asset_sync_queue() {
  $queue = Drupal::queue('media_acquiadam_asset_refresh');

  // We only want to re-queue everything when the queue is totally empty. This
  // should help minimize the number of duplicate syncs we perform on assets.
  if ($queue
    ->numberOfItems() > 0) {
    return $queue
      ->numberOfItems();
  }
  foreach (media_acquiadam_get_active_media_ids() as $media_id) {
    $queue
      ->createItem([
      'media_id' => $media_id,
    ]);
  }
  return $queue
    ->numberOfItems();
}