You are here

public function AcquiaDAM_Assets_AbstractAsset::setId in Media: Acquia DAM 7

Set the asset ID for the current asset.

Parameters

int $assetId: The asset ID to set.

bool $fetchAsset: TRUE to fetch the asset after setting.

Throws

BadMethodCallException

1 call to AcquiaDAM_Assets_AbstractAsset::setId()
AcquiaDAM_Assets_AbstractAsset::__construct in src/AcquiaDAM/AcquiaDAM_Assets_AbstractAsset.inc
Create an Asset.

File

src/AcquiaDAM/AcquiaDAM_Assets_AbstractAsset.inc, line 156

Class

AcquiaDAM_Assets_AbstractAsset
Abstract class base for Acquia DAM assets.

Code

public function setId($assetId, $fetchAsset = TRUE) {
  if (!empty($this->assetId)) {
    throw new BadMethodCallException('Unable to set asset ID once already set.');
  }
  $this->assetId = $this
    ->ensureIsValidAssetId($assetId);
  if (FALSE === $this->assetId) {
    throw new InvalidArgumentException(sprintf('Invalid asset ID given: %d', $assetId));
  }
  if ($fetchAsset) {
    $this
      ->get();
  }
}