You are here

public function Client::editAsset in Media: Acquia DAM 8

Edit an asset.

If an asset is uploaded and its required fields are not filled in, the asset is in onhold status and cannot be activated until all required fields are supplied. Any attempt to change the status to 'active' for assets that still require metadata will return back 409.

Parameters

int $assetID: The asset to edit.

array $data: An array of values to set. filename string The new filename for the asset. status string The new status of the asset. Either active or inactive. name string The new name for the asset. description string The new description of the asset. folder long The id of the folder to move asset to. thumbnail_ttl string Time to live for thumbnails Default: Set by the account admin Values: '+3 min', '+15 min', '+2 hours', '+1 day', '+2 weeks', 'no-expiration'.

Return value

\cweagans\webdam\Entity\Asset|bool An asset object on success, or FALSE on failure.

Throws

\GuzzleHttp\Exception\GuzzleException

\cweagans\webdam\Exception\InvalidCredentialsException

File

src/Client.php, line 387

Class

Client
Overridden implementation of the cweagans php-webdam-client.

Namespace

Drupal\media_acquiadam

Code

public function editAsset($assetID, array $data) {
  $this
    ->checkAuth();
  $response = $this->client
    ->request('PUT', $this->baseUrl . '/assets/' . $assetID, [
    'headers' => $this
      ->getDefaultHeaders(),
    RequestOptions::JSON => $data,
  ]);
  if (409 == $response
    ->getStatusCode()) {
    return FALSE;
  }
  $asset = Asset::fromJson((string) $response
    ->getBody());
  return $asset;
}