You are here

function hook_feeds_after_save in Feeds 8.2

Same name and namespace in other branches
  1. 7.2 feeds.api.php \hook_feeds_after_save()

Invoked after a feed item has been saved.

Parameters

FeedsSource $source: FeedsSource object that describes the source that is being imported.

$entity: The entity object that has just been saved.

array $item: The parser result for this entity.

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_after_save()
FeedsProcessor::process in lib/Drupal/feeds/Plugin/FeedsProcessor.php
Process the result of the parsing stage.

File

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

Code

function hook_feeds_after_save(FeedsSource $source, $entity, $item, $entity_id) {

  // Use $entity->nid of the saved node.
  // Although the $entity object is passed by reference, any changes made in
  // this function will be ignored by the FeedsProcessor.
  $config = $source->importer
    ->getConfig();
  if ($config['processor']['config']['purge_unseen_items'] && isset($entity->feeds_item)) {
    $feeds_item = $entity->feeds_item;
    $feeds_item->batch_id = feeds_delete_get_current_batch($feeds_item->feed_nid);
    drupal_write_record('feeds_delete_item', $feeds_item);
  }
}