You are here

public function Feed::deleteItems in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/src/Entity/Feed.php \Drupal\aggregator\Entity\Feed::deleteItems()

Deletes all items from a feed.

This will also reset the last checked and modified time of the feed and save it.

Return value

$this The class instance that this method is called on.

Overrides FeedInterface::deleteItems

See also

\Drupal\aggregator\ItemsImporterInterface::delete()

File

core/modules/aggregator/src/Entity/Feed.php, line 68

Class

Feed
Defines the aggregator feed entity class.

Namespace

Drupal\aggregator\Entity

Code

public function deleteItems() {
  \Drupal::service('aggregator.items.importer')
    ->delete($this);

  // Reset feed.
  $this
    ->setLastCheckedTime(0);
  $this
    ->setHash('');
  $this
    ->setEtag('');
  $this
    ->setLastModified(0);
  $this
    ->save();
  return $this;
}