You are here

protected function LingotekDisassociateAllConfirmForm::disassociateAllContentTranslations in Lingotek Translation 3.1.x

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

Disassociate all content translations.

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

File

src/Form/LingotekDisassociateAllConfirmForm.php, line 164

Class

LingotekDisassociateAllConfirmForm
Show a warning before disassociate all content.

Namespace

Drupal\lingotek\Form

Code

protected function disassociateAllContentTranslations() {
  $error = FALSE;

  /** @var \Drupal\lingotek\Entity\LingotekContentMetadata[] $all_content_metadata */
  $all_content_metadata = LingotekContentMetadata::loadMultiple();
  foreach ($all_content_metadata as $content_metadata) {
    try {
      $content_metadata
        ->delete();
    } catch (LingotekApiException $exception) {
      $error = TRUE;
      $this
        ->messenger()
        ->addError(t('The disassociation of @entity_type %title failed. Please try again.', [
        '@entity_type' => $content_metadata
          ->getContentEntityTypeId(),
        '%title' => $content_metadata
          ->id(),
      ]));
    }
  }
  if ($error) {
    $this
      ->messenger()
      ->addWarning($this
      ->t('Some translations may have been disassociated, but some failed.'));
  }
  else {
    $this
      ->messenger()
      ->addStatus($this
      ->t('All translations have been disassociated.'));
  }
  return $error;
}