/** * Schedule background expire tasks. * * This is also used as a callback for job_scheduler integration. * * @param \Drupal\feeds\FeedInterface $feed * The feed to schedule. */ public function scheduleExpire(FeedInterface $feed) { if (!$this->jobController) { return; } // Schedule as soon as possible if a batch is active. $period = $feed->progressExpiring() === StateInterface::BATCH_COMPLETE ? 3600 : 0; $job = array('name' => 'feeds_feed_expire', 'type' => $feed->bundle(), 'id' => $feed->id(), 'period' => $period, 'periodic' => TRUE); if ($feed->getImporter()->getProcessor()->expiryTime() == SchedulerInterface::EXPIRE_NEVER) { $this->jobController->remove($job); } else { $this->jobController->set($job); } }
protected function getUniqueQuery(FeedInterface $feed) { if (!isset(static::$uniqueQueries[$feed->id()])) { $entity_type = $feed->getImporter()->getProcessor()->entityType(); static::$uniqueQueries[$feed->id()] = \Drupal::entityQuery($entity_type)->condition('feeds_item.target_id', $feed->id())->range(0, 1); } return clone static::$uniqueQueries[$feed->id()]; }