You are here

public function FeedsSource::clear in Feeds 7

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

Remove all items from a feed.

Return value

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

Throws

Throws Exception if an error occurs when clearing.

File

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

Class

FeedsSource
This class encapsulates a source of a feed. It stores where the feed can be found and how to import it.

Code

public function clear() {
  try {
    $this->importer->fetcher
      ->clear($this);
    $this->importer->parser
      ->clear($this);
    if (!$this->batch || !$this->batch instanceof FeedsClearBatch) {
      $this->batch = new FeedsClearBatch();
    }
    $this->importer->processor
      ->clear($this->batch, $this);
    $result = $this->batch
      ->getProgress();
    if ($result == FEEDS_BATCH_COMPLETE) {
      unset($this->batch);
      module_invoke_all('feeds_after_clear', $this->importer, $this);
    }
  } catch (Exception $e) {
    unset($this->batch);
    $this
      ->save();
    throw $e;
  }
  $this
    ->save();
  return $result;
}