You are here

public function AssetFeedsProcessor::setTargetElement in Asset 7

Override setTargetElement to operate on a target item that is an asset.

File

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

Class

AssetFeedsProcessor
Creates assets from feed items.

Code

public function setTargetElement(FeedsSource $source, $target_asset, $target_element, $value) {
  switch ($target_element) {
    case 'created':
      $target_asset->created = feeds_to_unixtime($value, REQUEST_TIME);
      break;
    case 'feeds_source':

      // Get the class of the feed asset importer's fetcher and set the source
      // property. See asset_feeds_asset_update() how $asset->feeds gets stored.
      if ($id = feeds_get_importer_id($this->config['asset_type'])) {
        $class = get_class(feeds_importer($id)->fetcher);
        $target_asset->feeds[$class]['source'] = $value;

        // This effectively suppresses 'import on submission' feature.
        // See asset_feeds_asset_insert().
        $target_asset->feeds['suppress_import'] = TRUE;
      }
      break;
    default:
      parent::setTargetElement($source, $target_asset, $target_element, $value);
      break;
  }
}