public function LingotekManagementFormBase::cancel in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8.2 src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 4.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.2.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.3.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.4.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.5.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.6.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.7.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
- 3.8.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::cancel()
Cancel the content from Lingotek.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
File
- src/
Form/ LingotekManagementFormBase.php, line 1302
Class
- LingotekManagementFormBase
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function cancel(ContentEntityInterface $entity, $language, $job_id, &$context) {
$context['message'] = $this
->t('Cancelling all translations for @type %label.', [
'@type' => $entity
->getEntityType()
->getLabel(),
'%label' => $entity
->label(),
]);
if ($profile = $this->lingotekConfiguration
->getEntityProfile($entity, FALSE)) {
try {
$this->translationService
->cancelDocument($entity);
} catch (LingotekApiException $exception) {
$this
->messenger()
->addError(t('The cancellation of @entity_type %title failed. Please try again.', [
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
]));
}
}
else {
$bundleInfos = $this->entityTypeBundleInfo
->getBundleInfo($entity
->getEntityTypeId());
$this
->messenger()
->addWarning($this
->t('The @type %label has no profile assigned so it was not processed.', [
'@type' => $bundleInfos[$entity
->bundle()]['label'],
'%label' => $entity
->label(),
]));
}
}