You are here

public function BynderApi::addAssetUsage in Bynder 8.3

Same name and namespace in other branches
  1. 8 src/BynderApi.php \Drupal\bynder\BynderApi::addAssetUsage()
  2. 8.2 src/BynderApi.php \Drupal\bynder\BynderApi::addAssetUsage()
  3. 4.0.x src/BynderApi.php \Drupal\bynder\BynderApi::addAssetUsage()

Creates an asset usage entry in Bynder.

Parameters

string $asset_id: Bynder asset ID.

\Drupal\Core\Url $usage_url: Url where the asset is being used (node url).

string $creation_date: Date the asset was added to the page, in the DATE_ISO8601 format.

string $additional_info: Any additional info to be displayed with the entry information.

Return value

mixed

Overrides BynderApiInterface::addAssetUsage

1 method overrides BynderApi::addAssetUsage()
BynderApiTest::addAssetUsage in tests/modules/bynder_test_module/src/BynderApiTest.php
Sets values in state.

File

src/BynderApi.php, line 409

Class

BynderApi
Bynder API service.

Namespace

Drupal\bynder

Code

public function addAssetUsage($asset_id, $usage_url, $creation_date, $additional_info = NULL) {
  $usage_properties = [
    'integration_id' => self::BYNDER_INTEGRATION_ID,
    'asset_id' => $asset_id,
    'timestamp' => $creation_date,
    'uri' => $usage_url
      ->setAbsolute(TRUE)
      ->toString(),
    'additional' => $additional_info,
  ];
  return $this
    ->getAssetBankManager()
    ->createUsage($usage_properties)
    ->wait();
}