public function LingotekContentTranslationService::requestTranslations in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::requestTranslations()
Requests translations of a document in all the enabled locales.
Parameters
\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity being requested for translations.
Overrides LingotekContentTranslationServiceInterface::requestTranslations
File
- src/
LingotekContentTranslationService.php, line 579 - Contains \Drupal\lingotek\LingotekContentTranslationService.
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function requestTranslations(ContentEntityInterface &$entity) {
$languages = [];
if ($document_id = $this
->getDocumentId($entity)) {
$target_languages = $this->languageManager
->getLanguages();
$target_languages = array_filter($target_languages, function (LanguageInterface $language) {
$configLanguage = ConfigurableLanguage::load($language
->getId());
return $this->lingotekConfiguration
->isLanguageEnabled($configLanguage);
});
$entity_langcode = $entity
->getUntranslated()
->language()
->getId();
foreach ($target_languages as $langcode => $language) {
$locale = $this->languageLocaleMapper
->getLocaleForLangcode($langcode);
if ($langcode !== $entity_langcode) {
$source_status = $this
->getSourceStatus($entity);
$current_status = $this
->getTargetStatus($entity, $langcode);
if ($current_status !== Lingotek::STATUS_PENDING && $current_status !== Lingotek::STATUS_CURRENT && $current_status !== Lingotek::STATUS_EDITED && $current_status !== Lingotek::STATUS_READY) {
if ($this->lingotek
->addTarget($document_id, $locale, $this->lingotekConfiguration
->getEntityProfile($entity))) {
$languages[] = $langcode;
$this
->setTargetStatus($entity, $langcode, Lingotek::STATUS_PENDING);
// If the status was "Importing", and the target was added
// successfully, we can ensure that the content is current now.
if ($source_status == Lingotek::STATUS_IMPORTING) {
$this
->setSourceStatus($entity, Lingotek::STATUS_CURRENT);
}
}
}
}
}
}
return $languages;
}