You are here

function tmgmt_extension_suit_tmgmt_job_item_presave in TMGMT Extension Suite 8.2

Same name and namespace in other branches
  1. 8.3 tmgmt_extension_suit.module \tmgmt_extension_suit_tmgmt_job_item_presave()
  2. 8 tmgmt_extension_suit.module \tmgmt_extension_suit_tmgmt_job_item_presave()

Implements hook_ENTITY_TYPE_presave().

File

./tmgmt_extension_suit.module, line 238

Code

function tmgmt_extension_suit_tmgmt_job_item_presave(EntityInterface $job_item) {

  // Create hash for job item while creation process. We only need to update
  // job item hash in case source entity was updated in Drupal.
  // @see tmgmt_extension_suit_entity_update().
  $old_hash = $job_item
    ->get('tes_source_content_hash')
    ->getValue();
  $old_hash = isset($old_hash[0]['value']) ? $old_hash[0]['value'] : '';
  if ('' != $old_hash) {
    return;
  }
  $hash = _tmgmt_extension_suit_get_job_item_hash($job_item);
  if ($hash !== '') {
    $job_item
      ->set('tes_source_content_hash', $hash);
  }
}