You are here

protected function EntityProcessorBase::initCleanList in Feeds 8.3

Initializes the list of entities to clean.

This populates $state->cleanList with all existing entities previously imported from the source.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed to import.

\Drupal\feeds\Feeds\State\CleanStateInterface $state: The state of the clean stage.

1 call to EntityProcessorBase::initCleanList()
EntityProcessorBase::process in src/Feeds/Processor/EntityProcessorBase.php
Processes the results from a parser.

File

src/Feeds/Processor/EntityProcessorBase.php, line 227

Class

EntityProcessorBase
Defines a base entity processor.

Namespace

Drupal\feeds\Feeds\Processor

Code

protected function initCleanList(FeedInterface $feed, CleanStateInterface $state) {
  $state
    ->setEntityTypeId($this
    ->entityType());

  // Fill the list only if needed.
  if ($this
    ->getConfiguration('update_non_existent') === static::KEEP_NON_EXISTENT) {
    return;
  }

  // Set list of entities to clean.
  $ids = $this->entityTypeManager
    ->getStorage($this
    ->entityType())
    ->getQuery()
    ->condition('feeds_item.target_id', $feed
    ->id())
    ->condition('feeds_item.hash', $this
    ->getConfiguration('update_non_existent'), '<>')
    ->execute();
  $state
    ->setList($ids);

  // And set progress.
  $state->total = $state
    ->count();
  $state
    ->progress($state->total, 0);
}