You are here

protected function LingotekSettingsTabUtilitiesForm::disassociateAllConfigTranslations in Lingotek Translation 8

Disassociate all config translations.

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

File

src/Form/LingotekSettingsTabUtilitiesForm.php, line 182
Contains \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm.

Class

LingotekSettingsTabUtilitiesForm
Tab for running Lingotek utilities in the settings page.

Namespace

Drupal\lingotek\Form

Code

protected function disassociateAllConfigTranslations() {
  $error = FALSE;

  /** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.config_translation');

  /** @var 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();
        $translation_service
          ->deleteMetadata($entity);
      }
      else {
        $translation_service
          ->deleteConfigMetadata($mapper
          ->getPluginId());
      }
    } catch (LingotekApiException $exception) {
      $error = TRUE;
      drupal_set_message(t('The deletion of %title failed. Please try again.', array(
        '%title' => $dependency_name,
      )), 'error');
    }
  }
  return $error;
}