You are here

protected function AssetRefreshManager::extractAssetIds in Media: Acquia DAM 8

Extracts asset id values from the response body.

Parameters

array $notifications: Notification items.

Return value

array List of asset ids.

1 call to AssetRefreshManager::extractAssetIds()
AssetRefreshManager::getAssetIds in src/Service/AssetRefreshManager.php
Returns the most recent media asset ids.

File

src/Service/AssetRefreshManager.php, line 289

Class

AssetRefreshManager
Class AssetRefreshManager.

Namespace

Drupal\media_acquiadam\Service

Code

protected function extractAssetIds(array $notifications) : array {
  $asset_ids = [];
  foreach ($notifications as $item) {
    if (!in_array($item['action'], $this
      ->getActionsToTrack(), TRUE)) {
      continue;
    }
    if (isset($item['source']['type']) && in_array($item['source']['type'], $this
      ->getItemsTypesToTrack(), TRUE)) {
      $asset_ids[] = $item['source']['id'];
    }
    if (!isset($item['subitems']) || !is_array($item['subitems'])) {
      continue;
    }
    foreach ($item['subitems'] as $subitem) {
      if (!isset($subitem['type'], $subitem['id'])) {
        continue;
      }
      if (!in_array($subitem['type'], $this
        ->getItemsTypesToTrack(), TRUE)) {
        continue;
      }
      if (in_array($subitem['id'], $asset_ids)) {
        continue;
      }
      $asset_ids[] = $subitem['id'];
    }
  }
  return array_unique($asset_ids);
}