You are here

function salesforce_push_cron in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_push/salesforce_push.module \salesforce_push_cron()
  2. 7.3 modules/salesforce_push/salesforce_push.module \salesforce_push_cron()
  3. 5.0.x modules/salesforce_push/salesforce_push.module \salesforce_push_cron()

Implements hook_cron().

File

modules/salesforce_push/salesforce_push.module, line 236
Push updates to Salesforce when a Drupal entity is updated.

Code

function salesforce_push_cron() {
  $queue = \Drupal::service('queue.salesforce_push');
  if (\Drupal::config('salesforce.settings')
    ->get('standalone')) {

    // If global standalone processing is enabled, stop here.
    return;
  }
  try {

    // Process mappings only for those which are not marked standalone.
    $mappings = \Drupal::service('entity_type.manager')
      ->getStorage('salesforce_mapping')
      ->loadCronPushMappings();
    if (empty($mappings)) {
      return;
    }
    $queue
      ->processQueues($mappings);
  } catch (\Exception $e) {
    \Drupal::service('event_dispatcher')
      ->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e));
  }
}