You are here

protected function AssetFeedsProcessor::entityLoad in Asset 7

Loads an existing asset.

If the update existing method is not FEEDS_UPDATE_EXISTING, only the asset table will be loaded for better performance.

File

modules/asset_feeds/AssetFeedsProcessor.inc, line 48
Class definition of AssetFeedsProcessor.

Class

AssetFeedsProcessor
Creates assets from feed items.

Code

protected function entityLoad(FeedsSource $source, $aid) {
  if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
    $asset = asset_load($aid, TRUE);
  }
  else {

    // We're replacing the existing entity. Only save the absolutely necessary.
    $asset = new Asset(array(
      'aid' => $aid,
      'uid' => $this->config['author'],
    ));
    $asset = db_query("SELECT created, nid, type FROM {asset} WHERE aid = :aid", array(
      ':aid' => $aid,
    ))
      ->fetchObject();
    $asset->uid = $this->config['author'];
  }
  return $asset;
}