You are here

public function LingotekCliService::checkTranslationsStatuses in Lingotek Translation 3.1.x

Same name and namespace in other branches
  1. 8.2 src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  2. 4.0.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  3. 3.0.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  4. 3.2.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  5. 3.3.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  6. 3.4.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  7. 3.5.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  8. 3.6.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  9. 3.7.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()
  10. 3.8.x src/Cli/LingotekCliService.php \Drupal\lingotek\Cli\LingotekCliService::checkTranslationsStatuses()

File

src/Cli/LingotekCliService.php, line 136

Class

LingotekCliService

Namespace

Drupal\lingotek\Cli

Code

public function checkTranslationsStatuses($entity_type_id, $entity_id, $langcodes = [
  'all',
]) {
  $entity = $this
    ->getEntity($entity_type_id, $entity_id);
  if ($entity instanceof EntityInterface) {
    $this->translationService
      ->checkTargetStatuses($entity);
    $languages = $this->translationService
      ->getTargetStatuses($entity);
    unset($languages[$entity
      ->getUntranslated()
      ->language()
      ->getId()]);
    $result = [];
    foreach ($languages as $langcode => $status) {
      if (!in_array('all', $langcodes)) {
        if (!in_array($langcode, $langcodes)) {
          continue;
        }
      }
      $result[$langcode] = [
        'langcode' => $langcode,
        'status' => $status,
      ];
    }
    return $result;
  }

  // Contains an error message.
  return $entity;
}