function drush_salesforce_pull_sf_pull_query in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 modules/salesforce_pull/salesforce_pull.drush.inc \drush_salesforce_pull_sf_pull_query()
- 5.0.x modules/salesforce_pull/salesforce_pull.drush.inc \drush_salesforce_pull_sf_pull_query()
Queues records for pull from salesforce for the given mapping.
Parameters
string $name: Mapping name.
Deprecated
Support for drush 8 is deprecated and will be removed in a future release.
File
- modules/
salesforce_pull/ salesforce_pull.drush.inc, line 98 - Salesforce Pull drush 8 commands.
Code
function drush_salesforce_pull_sf_pull_query($name) {
_drush_salesforce_deprecated();
if (!($mapping = _salesforce_drush_get_mapping($name))) {
return;
}
$start = 0;
if ($start = drush_get_option('start')) {
$start = strtotime($start);
}
$stop = 0;
if ($stop = drush_get_option('stop')) {
$stop = strtotime($stop);
}
$where = drush_get_option('where');
if (!($soql = $mapping
->getPullQuery([], $start, $stop))) {
drush_log(dt('!mapping: Unable to generate pull query. Does this mapping have any Salesforce Action Triggers enabled?', [
'!mapping' => $mapping
->id(),
]), 'error');
return;
}
if ($where) {
$soql->conditions[] = [
$where,
];
}
\Drupal::service('event_dispatcher')
->dispatch(SalesforceEvents::PULL_QUERY, new SalesforceQueryEvent($mapping, $soql));
drush_log(dt('!mapping: Issuing pull query: !query', [
'!query' => (string) $soql,
'!mapping' => $mapping
->id(),
]), 'notice');
$results = \Drupal::service('salesforce.client')
->query($soql);
if (empty($results)) {
drush_log(dt('!mapping: No records found to pull.', [
'!mapping' => $mapping
->id(),
]), 'warning');
return;
}
$force_pull = drush_get_option('force-pull') ? TRUE : FALSE;
\Drupal::service('salesforce_pull.queue_handler')
->enqueueAllResults($mapping, $results, $force_pull);
drush_log(dt('!mapping: Queued !count items for pull.', [
'!count' => $results
->size(),
'!mapping' => $mapping
->id(),
]), 'success');
}