You are here

public function LingotekManagementForm::checkDocumentUploadStatus in Lingotek Translation 8

Check document upload status for a given content.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

File

src/Form/LingotekManagementForm.php, line 744
Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Class

LingotekManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

public function checkDocumentUploadStatus(ContentEntityInterface $entity, $language, &$context) {
  $context['message'] = $this
    ->t('Checking status of @type %label.', [
    '@type' => $entity
      ->getEntityType()
      ->getLabel(),
    '%label' => $entity
      ->label(),
  ]);
  if ($profile = $this->lingotekConfiguration
    ->getEntityProfile($entity, FALSE)) {
    try {
      $this->translationService
        ->checkSourceStatus($entity);
    } catch (LingotekApiException $exception) {
      drupal_set_message(t('The upload status check for @entity_type %title translation failed. Please try again.', array(
        '@entity_type' => $entity
          ->getEntityTypeId(),
        '%title' => $entity
          ->label(),
      )), 'error');
    }
  }
  else {
    $bundleInfos = $this->entityManager
      ->getBundleInfo($entity
      ->getEntityTypeId());
    drupal_set_message($this
      ->t('The @type %label has no profile assigned so it was not processed.', [
      '@type' => $bundleInfos[$entity
        ->bundle()]['label'],
      '%label' => $entity
        ->label(),
    ]), 'warning');
  }
}