You are here

public function FeedsSource::clear in Feeds 7.2

Same name and namespace in other branches
  1. 6 includes/FeedsSource.inc \FeedsSource::clear()
  2. 7 includes/FeedsSource.inc \FeedsSource::clear()

Remove all items from a feed.

This method only executes the current batch chunk, then returns. If you are looking to delete all items of a source, use FeedsSource::startClear() instead.

Return value

float FEEDS_BATCH_COMPLETE if the clearing process finished. A decimal between 0.0 and 0.9 periodic if clearing is still in progress.

Throws

Exception In case an error occurs when clearing.

File

includes/FeedsSource.inc, line 636
Definition of FeedsSourceInterface, FeedsState and FeedsSource class.

Class

FeedsSource
Holds the source of a feed to import.

Code

public function clear() {
  $this
    ->acquireLock();
  try {
    $this->importer->fetcher
      ->clear($this);
    $this->importer->parser
      ->clear($this);
    $this->importer->processor
      ->clear($this);
  } catch (Exception $e) {

    // $e is stored and re-thrown once we've had a chance to log our progress.
  }
  $this
    ->releaseLock();

  // Clean up.
  $result = $this
    ->progressClearing();
  if ($result == FEEDS_BATCH_COMPLETE || isset($e)) {
    module_invoke_all('feeds_after_clear', $this);
    $this
      ->clearStates();
  }
  $this
    ->save();
  if (isset($e)) {
    throw $e;
  }
  return $result;
}