You are here

function hook_feeds_before_update in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.api.php \hook_feeds_before_update()

Invoked before a feed item is updated/created/replaced.

This is called every time a feed item is processed no matter if the item gets updated or not.

Parameters

FeedsSource $source: The source for the current feed.

array $item: All the current item from the feed.

int|null $entity_id: The id of the current item which is going to be updated. If this is a new item, then NULL is passed.

Related topics

1 invocation of hook_feeds_before_update()
FeedsProcessor::process in plugins/FeedsProcessor.inc
Process the result of the parsing stage.

File

./feeds.api.php, line 132
Documentation of Feeds hooks.

Code

function hook_feeds_before_update(FeedsSource $source, $item, $entity_id) {
  if ($entity_id) {
    $processor = $source->importer->processor;
    db_update('foo_bar')
      ->fields(array(
      'entity_type' => $processor
        ->entityType(),
      'entity_id' => $entity_id,
      'last_seen' => REQUEST_TIME,
    ))
      ->condition('entity_type', $processor
      ->entityType())
      ->condition('entity_id', $entity_id)
      ->execute();
  }
}