function tmgmt_content_create_continuous_job_items

Creates continuous job items for entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity to be inserted or updated.

Return value

int Number of created continuous job items.

4 calls to tmgmt_content_create_continuous_job_items()
ContentEntitySourcePluginUi::createContinuousJobItemsBatch in sources/content/src/ContentEntitySourcePluginUi.php
Creates continuous job items for entity.
ContentEntitySourcePluginUi::overviewSubmitToContinuousJobs in sources/content/src/ContentEntitySourcePluginUi.php
Adds selected sources to continuous jobs.
tmgmt_content_entity_insert in sources/content/tmgmt_content.module
Implements hook_entity_insert().
tmgmt_content_entity_update in sources/content/tmgmt_content.module
Implements hook_entity_update().

File

sources/content/tmgmt_content.module, line 329
Source plugin for the Translation Management system that handles entities.

Code

function tmgmt_content_create_continuous_job_items(ContentEntityInterface $entity) {
  $job_items_count = 0;
  $entity = $entity
    ->getUntranslated();
  $source_langcode = $entity
    ->language()
    ->getId();
  $content_translation_manager = \Drupal::service('content_translation.manager');
  if ($content_translation_manager
    ->isEnabled($entity
    ->getEntityTypeId(), $entity
    ->bundle())) {
    $continuous_manager = \Drupal::service('tmgmt.continuous');
    $jobs = $continuous_manager
      ->getContinuousJobs($source_langcode);
    foreach ($jobs as $job) {
      if ($continuous_manager
        ->addItem($job, 'content', $entity
        ->getEntityTypeId(), $entity
        ->id())) {
        $job_items_count++;
      }
    }
  }
  return $job_items_count;
}