Checks whether the continuous job item should be created.
\Drupal\tmgmt\Entity\Job $job: Continuous job.
string $plugin: The plugin name.
string $item_type: The source item type.
string $item_id: The source item id.
bool TRUE if continuous job item should be created, FALSE if not.
Overrides ContinuousSourceInterface::shouldCreateContinuousItem
public function shouldCreateContinuousItem(Job $job, $plugin, $item_type, $item_id) {
$continuous_settings = $job
->getContinuousSettings();
$entity = static::load($item_type, $item_id, $job
->getSourceLangcode());
$translation_manager = \Drupal::service('content_translation.manager');
$translation = $entity
->hasTranslation($job
->getTargetLangcode()) ? $entity
->getTranslation($job
->getTargetLangcode()) : NULL;
$metadata = isset($translation) ? $translation_manager
->getTranslationMetadata($translation) : NULL;
// If a translation exists and is not marked as outdated, no new job items
// needs to be created.
if (isset($translation) && !$metadata
->isOutdated()) {
return FALSE;
}
else {
if ($entity && $entity
->getEntityType()
->hasKey('bundle')) {
// The entity type has bundles, check both the entity type setting and
// the bundle.
if (!empty($continuous_settings[$plugin][$item_type]['bundles'][$entity
->bundle()]) && !empty($continuous_settings[$plugin][$item_type]['enabled'])) {
return TRUE;
}
}
elseif (!empty($continuous_settings[$plugin][$item_type]['enabled'])) {
return TRUE;
}
}
return FALSE;
}