Returns conflicting job item IDs along with the jobs causing the conflicts.
Conflicting job items are those that already have an identical item in another job that is not yet finished.
array List of conflicting job item IDs and existing jobs.
Overrides JobInterface::getConflictingItems
public function getConflictingItems() {
$conflicting_items = [];
foreach ($this
->getItems() as $item) {
// Get existing job items that are have the same languages, same source,
// are active or in review and are not the job item that we are checking.
$existing_items = \Drupal::entityQuery('tmgmt_job_item')
->accessCheck(TRUE)
->condition('state', [
JobItemInterface::STATE_ACTIVE,
JobItemInterface::STATE_REVIEW,
], 'IN')
->condition('plugin', $item
->getPlugin())
->condition('item_type', $item
->getItemType())
->condition('item_id', $item
->getItemId())
->condition('tjiid', $item
->id(), '<>')
->condition('tjid.entity.source_language', $this
->getSourceLangcode())
->condition('tjid.entity.target_language', $this
->getTargetLangcode())
->execute();
// If there are any, this is a conflicting job item, so get the existing
// items that are causing the conflict.
if ($existing_items) {
$conflicting_items[$item
->id()] = $existing_items;
}
}
return $conflicting_items;
}