You are here

public function LingotekConfigTranslationService::setSourceStatus in Lingotek Translation 8

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

Sets the translation status of a given entity.

Parameters

ConfigEntityInterface &$entity: The entity which status we want to change.

int $status: Status of the translation. Use Lingotek class constants.

Return value

ConfigEntityInterface

Overrides LingotekConfigTranslationServiceInterface::setSourceStatus

6 calls to LingotekConfigTranslationService::setSourceStatus()
LingotekConfigTranslationService::addTarget in src/LingotekConfigTranslationService.php
Request a translation for a given entity in the given locale.
LingotekConfigTranslationService::checkSourceStatus in src/LingotekConfigTranslationService.php
Checks the source is uploaded correctly.
LingotekConfigTranslationService::downloadDocument in src/LingotekConfigTranslationService.php
Downloads a document from the Lingotek service for a given locale.
LingotekConfigTranslationService::requestTranslations in src/LingotekConfigTranslationService.php
Requests translations of a document in all the enabled locales.
LingotekConfigTranslationService::updateDocument in src/LingotekConfigTranslationService.php
Resends a document to the translation service.

... See full list

File

src/LingotekConfigTranslationService.php, line 203
Contains \Drupal\lingotek\LingotekConfigTranslationService.

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function setSourceStatus(ConfigEntityInterface &$entity, $status) {
  $source_language = NULL;
  $metadata = LingotekConfigMetadata::loadByConfigName($entity
    ->getEntityTypeId() . '.' . $entity
    ->id());
  $translation_source = $metadata
    ->getSourceStatus();
  if ($translation_source) {
    $source_language = key($translation_source);
  }
  if ($source_language == LanguageInterface::LANGCODE_NOT_SPECIFIED || $source_language == NULL) {
    $source_language = $entity
      ->language()
      ->getId();
  }
  $status_value = [
    $source_language => $status,
  ];
  $metadata
    ->setSourceStatus($status_value)
    ->save();
}