You are here

class LingotekJobManagementService in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  2. 4.0.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  3. 3.0.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  4. 3.1.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  5. 3.2.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  6. 3.3.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  7. 3.5.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  8. 3.6.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  9. 3.7.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService
  10. 3.8.x src/LingotekJobManagementService.php \Drupal\lingotek\LingotekJobManagementService

Hierarchy

Expanded class hierarchy of LingotekJobManagementService

File

src/LingotekJobManagementService.php, line 5

Namespace

Drupal\lingotek
View source
class LingotekJobManagementService {
  public function getAllContentJobs(array &$jobs) {
    $entity_query = \Drupal::entityQuery('lingotek_content_metadata');
    $entity_query
      ->exists('job_id');
    $ids = $entity_query
      ->execute();
    $metadatas = $this
      ->entityTypeManager()
      ->getStorage('lingotek_content_metadata')
      ->loadMultiple($ids);

    /** @var \Drupal\lingotek\Entity\LingotekContentMetadata $metadata */
    foreach ($metadatas as $metadata) {
      $job_id = $metadata
        ->getJobId();
      if (!empty($job_id)) {
        if (!isset($jobs[$job_id])) {
          $jobs[$job_id] = [
            'id' => $job_id,
            'content' => 0,
            'config' => 0,
          ];
        }
        ++$jobs[$job_id]['content'];
      }
    }
    return $jobs;
  }
  public function getAllConfigJobs(array &$jobs) {
    $entity_query = \Drupal::entityQuery('lingotek_config_metadata');
    $entity_query
      ->exists('job_id');
    $ids = $entity_query
      ->execute();
    $metadatas = $this
      ->entityTypeManager()
      ->getStorage('lingotek_config_metadata')
      ->loadMultiple($ids);

    /** @var \Drupal\lingotek\Entity\LingotekConfigMetadata $metadata */
    foreach ($metadatas as $metadata) {
      $job_id = $metadata
        ->getJobId();
      if (!empty($job_id)) {
        if (!isset($jobs[$job_id])) {
          $jobs[$job_id] = [
            'id' => $job_id,
            'content' => 0,
            'config' => 0,
          ];
        }
        ++$jobs[$job_id]['config'];
      }
    }
    return $jobs;
  }

}

Members