You are here

protected function LingotekDashboardController::getLanguageReport in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8 src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  2. 8.2 src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  3. 3.0.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  4. 3.1.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  5. 3.2.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  6. 3.3.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  7. 3.4.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  8. 3.5.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  9. 3.6.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  10. 3.7.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
  11. 3.8.x src/Controller/LingotekDashboardController.php \Drupal\lingotek\Controller\LingotekDashboardController::getLanguageReport()
2 calls to LingotekDashboardController::getLanguageReport()
LingotekDashboardController::endpoint in src/Controller/LingotekDashboardController.php
LingotekDashboardController::getLanguageDetails in src/Controller/LingotekDashboardController.php

File

src/Controller/LingotekDashboardController.php, line 314

Class

LingotekDashboardController
Returns responses for lingotek module setup routes.

Namespace

Drupal\lingotek\Controller

Code

protected function getLanguageReport(LanguageInterface $language, $active = 1, $enabled = 1) {
  $langcode = $language
    ->getId();
  $locale = $this->languageLocaleMapper
    ->getLocaleForLangcode($langcode);
  $configLanguage = $this->entityTypeManager
    ->getStorage('configurable_language')
    ->load($langcode);
  $types = $this
    ->getEnabledTypes();
  $stat = [
    'locale' => $locale,
    'xcode' => $langcode,
    'active' => $this->lingotek_configuration
      ->isLanguageEnabled($configLanguage) ? 1 : 0,
    'enabled' => 1,
    'source' => [
      'types' => $this
        ->getSourceTypeCounts($langcode),
      'total' => 0,
    ],
    'target' => [
      'types' => $this
        ->getTargetTypeCounts($langcode),
      'total' => 0,
    ],
  ];
  foreach ($types as $type) {
    $stat['source']['total'] += isset($stat['source']['types'][$type]) ? $stat['source']['types'][$type] : 0;
    $stat['target']['total'] += isset($stat['target']['types'][$type]) ? $stat['target']['types'][$type] : 0;
  }
  return $stat;
}