You are here

public function LingotekConfigTranslationController::checkUpload in Lingotek Translation 3.3.x

Same name and namespace in other branches
  1. 8 src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  2. 8.2 src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  3. 4.0.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  4. 3.0.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  5. 3.1.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  6. 3.2.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  7. 3.4.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  8. 3.5.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  9. 3.6.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  10. 3.7.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
  11. 3.8.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::checkUpload()
1 string reference to 'LingotekConfigTranslationController::checkUpload'
lingotek.routing.yml in ./lingotek.routing.yml
lingotek.routing.yml

File

src/Controller/LingotekConfigTranslationController.php, line 376

Class

LingotekConfigTranslationController

Namespace

Drupal\lingotek\Controller

Code

public function checkUpload($entity_type, $entity_id, Request $request) {
  if ($entity_type === $entity_id) {

    // It is not a config entity, but a config object.
    $definition = $this->configMapperManager
      ->getDefinition($entity_type);
    try {
      if ($this->translationService
        ->checkConfigSourceStatus($entity_type)) {
        $this
          ->messenger()
          ->addStatus($this
          ->t('%label status checked successfully', [
          '%label' => $definition['title'],
        ]));
      }
    } catch (LingotekApiException $e) {
      $this
        ->messenger()
        ->addError($this
        ->t('%label status check failed. Please try again.', [
        '%label' => $definition['title'],
      ]));
    }
    return $this
      ->redirectToConfigTranslateOverview($entity_type);
  }

  // Check if it's a field.
  if (substr($entity_type, -7) == '_fields') {

    // Hack for fields, the entity is field config.
    $entity_type = 'field_config';
  }
  $entity = $this
    ->entityTypeManager()
    ->getStorage($entity_type)
    ->load($entity_id);
  try {
    if ($this->translationService
      ->checkSourceStatus($entity)) {
      $this
        ->messenger()
        ->addStatus($this
        ->t('%label status checked successfully', [
        '%label' => $entity
          ->label(),
      ]));
    }
  } catch (LingotekApiException $e) {
    $this
      ->messenger()
      ->addError($this
      ->t('%label status check failed. Please try again.', [
      '%label' => $entity
        ->label(),
    ]));
  }
  return $this
    ->redirectToEntityTranslateOverview($entity_type, $entity_id);
}