You are here

public function QueueHandler::getUpdatedRecordsForMapping in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 modules/salesforce_pull/src/QueueHandler.php \Drupal\salesforce_pull\QueueHandler::getUpdatedRecordsForMapping()
  2. 5.0.x modules/salesforce_pull/src/QueueHandler.php \Drupal\salesforce_pull\QueueHandler::getUpdatedRecordsForMapping()

Fetch and enqueue records from Salesforce.

Given a mapping and optional timeframe, perform an API query for updated records and enqueue them into the pull queue.

Parameters

\Drupal\salesforce_mapping\Entity\SalesforceMappingInterface $mapping: The salesforce mapping for which to query.

bool $force_pull: Whether to force the queried records to be pulled.

int $start: Timestamp of starting window from which to pull records. If omitted, use ::getLastPullTime().

int $stop: Timestamp of ending window from which to pull records. If omitted, use "now".

Return value

false|int Return the number of records fetched by the pull query, or FALSE no query was executed.

See also

SalesforceMappingInterface

1 call to QueueHandler::getUpdatedRecordsForMapping()
QueueHandler::getUpdatedRecords in modules/salesforce_pull/src/QueueHandler.php
Pull updated records from Salesforce and place them in the queue.

File

modules/salesforce_pull/src/QueueHandler.php, line 164

Class

QueueHandler
Handles pull cron queue set up.

Namespace

Drupal\salesforce_pull

Code

public function getUpdatedRecordsForMapping(SalesforceMappingInterface $mapping, $force_pull = FALSE, $start = 0, $stop = 0) {
  if (!$mapping
    ->doesPull()) {
    return FALSE;
  }
  if ($start == 0 && $mapping
    ->getNextPullTime() > $this->time
    ->getRequestTime()) {

    // Skip this mapping, based on pull frequency.
    return FALSE;
  }
  $results = $this
    ->doSfoQuery($mapping, [], $start, $stop);
  if ($results) {
    $this
      ->enqueueAllResults($mapping, $results, $force_pull);
    return $results
      ->size();
  }
}