public function PushQueue::failItem in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 modules/salesforce_push/src/PushQueue.php \Drupal\salesforce_push\PushQueue::failItem()
- 5.0.x modules/salesforce_push/src/PushQueue.php \Drupal\salesforce_push\PushQueue::failItem()
Failed item handler.
Exception handler so that Queue Processors don't have to worry about what happens when a queue item fails.
Parameters
\Throwable $e: The exception which caused the failure.
object $item: The failed item.
Overrides PushQueueInterface::failItem
File
- modules/
salesforce_push/ src/ PushQueue.php, line 508
Class
- PushQueue
- Salesforce push queue.
Namespace
Drupal\salesforce_pushCode
public function failItem(\Throwable $e, \stdClass $item) {
$mapping = $this->mappingStorage
->load($item->name);
if ($e instanceof EntityNotFoundException) {
// If there was an exception loading any entities,
// we assume that this queue item is no longer relevant.
$message = 'Exception while loading entity %type %id for salesforce mapping %mapping. Queue item deleted.';
$args = [
'%type' => $mapping
->get('drupal_entity_type'),
'%id' => $item->entity_id,
'%mapping' => $mapping
->id(),
];
$this->eventDispatcher
->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args));
$this
->deleteItem($item);
return;
}
$item->failures++;
$message = $e
->getMessage();
if ($item->failures >= $this->maxFails) {
$message = 'Permanently failed queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message;
}
else {
$message = 'Queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message;
}
$args = [
'%type' => $mapping
->get('drupal_entity_type'),
'%id' => $item->entity_id,
'%mapping' => $mapping
->id(),
'%item' => $item->item_id,
'%fail' => $item->failures,
];
$this->eventDispatcher
->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args));
// Failed items will remain in queue, but not be released. They'll be
// retried only when the current lease expires.
// doCreateItem() doubles as "save" function.
$this
->doCreateItem(get_object_vars($item));
}