You are here

public function BynderMediaApi::addAssetUsage in Bynder 7

File

includes/BynderMediaApi.inc, line 256
Manages the Bynder media browser functionality

Class

BynderMediaApi

Code

public function addAssetUsage($assetID, $usageUrl, $usageAdditional = null, $timestamp = null) {
  try {
    $usageProperties = [
      'integration_id' => self::BYNDER_INTEGRATION_ID,
      'asset_id' => $assetID,
      'timestamp' => isset($timestamp) ? $timestamp : date(DateTime::ISO8601),
      'uri' => $usageUrl,
      'additional' => $usageAdditional,
    ];
    return $this->assetBankManager
      ->createUsage($usageProperties)
      ->wait();
  } catch (Exception $e) {
    watchdog('bynder', $e
      ->getMessage());
    drupal_set_message(t('Could not add asset usage information'), 'error');
    return false;
  }
}