public function LingotekConfigSubscriber::onConfigLanguageOverrideDelete in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.0.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.1.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.2.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.3.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.4.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.5.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.6.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.7.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
- 3.8.x src/EventSubscriber/LingotekConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekConfigSubscriber::onConfigLanguageOverrideDelete()
Updates the Lingotek configuration when a field is deleted.
Parameters
\Drupal\Core\Config\ConfigCrudEvent $event: The configuration event.
File
- src/
EventSubscriber/ LingotekConfigSubscriber.php, line 198
Class
- LingotekConfigSubscriber
- Updates config Lingotek translation status when saved.
Namespace
Drupal\lingotek\EventSubscriberCode
public function onConfigLanguageOverrideDelete(LanguageConfigOverrideCrudEvent $event) {
if (!InstallerKernel::installationAttempted()) {
/** @var \Drupal\lingotek\LanguageLocaleMapperInterface $languageMapper */
$languageMapper = \Drupal::service('lingotek.language_locale_mapper');
$configOverride = $event
->getLanguageConfigOverride();
$config_name = $configOverride
->getName();
$mapper = $this
->getMapperFromConfigName($config_name);
if ($mapper !== NULL) {
if ($mapper instanceof ConfigEntityMapper) {
$entity = $mapper
->getEntity();
$document_id = $this->translationService
->getDocumentId($entity);
$translation_statuses = \Drupal::service('lingotek')
->getDocumentTranslationStatuses($document_id);
foreach ($translation_statuses as $lingotek_locale => $progress) {
$drupal_language = $languageMapper
->getConfigurableLanguageForLocale($lingotek_locale);
if ($drupal_language !== NULL && $drupal_language
->getId() === $configOverride
->getLangcode()) {
if ($progress === Lingotek::PROGRESS_COMPLETE) {
$this->translationService
->setTargetStatus($entity, $configOverride
->getLangcode(), Lingotek::STATUS_READY);
}
else {
$this->translationService
->setTargetStatus($entity, $configOverride
->getLangcode(), Lingotek::STATUS_PENDING);
}
return;
}
}
}
else {
$document_id = $this->translationService
->getConfigDocumentId($mapper);
$translation_statuses = \Drupal::service('lingotek')
->getDocumentTranslationStatuses($document_id);
foreach ($translation_statuses as $lingotek_locale => $progress) {
$drupal_language = $languageMapper
->getConfigurableLanguageForLocale($lingotek_locale);
if ($drupal_language
->getId() === $configOverride
->getLangcode()) {
if ($progress === Lingotek::PROGRESS_COMPLETE) {
$this->translationService
->setConfigTargetStatus($mapper, $configOverride
->getLangcode(), Lingotek::STATUS_READY);
}
else {
$this->translationService
->setConfigTargetStatus($mapper, $configOverride
->getLangcode(), Lingotek::STATUS_PENDING);
}
return;
}
}
}
}
}
}