You are here

protected function LingotekDisassociateAllConfirmForm::disassociateAllConfigTranslations in Lingotek Translation 4.0.x

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

Disassociate all config translations.

1 call to LingotekDisassociateAllConfirmForm::disassociateAllConfigTranslations()
LingotekDisassociateAllConfirmForm::disassociateAllTranslations in src/Form/LingotekDisassociateAllConfirmForm.php
Disassociate all content and config translations.

File

src/Form/LingotekDisassociateAllConfirmForm.php, line 132

Class

LingotekDisassociateAllConfirmForm
Show a warning before disassociate all content.

Namespace

Drupal\lingotek\Form

Code

protected function disassociateAllConfigTranslations() {
  $error = FALSE;

  /** @var \Drupal\lingotek\Entity\LingotekConfigMetadata[] $all_config_metadata */
  $all_config_metadata = LingotekConfigMetadata::loadMultiple();
  foreach ($all_config_metadata as $config_metadata) {
    try {
      $mapper = $config_metadata
        ->getConfigMapper();
      if ($mapper instanceof ConfigEntityMapper) {
        $entity = $mapper
          ->getEntity();
        $this->configTranslationService
          ->deleteMetadata($entity);
      }
      else {
        $this->configTranslationService
          ->deleteConfigMetadata($mapper
          ->getPluginId());
      }
    } catch (LingotekApiException $exception) {
      $error = TRUE;
      if ($mapper instanceof ConfigEntityMapper) {
        $this
          ->messenger()
          ->addError(t('The deletion of %title failed. Please try again.', [
          '%title' => $mapper
            ->getEntity()
            ->label(),
        ]));
      }
      else {
        $this
          ->messenger()
          ->addError(t('The deletion of %title failed. Please try again.', [
          '%title' => $mapper
            ->getPluginId(),
        ]));
      }
    }
  }
  return $error;
}