public function LingotekManagementForm::changeProfile in Lingotek Translation 8
Change Translation Profile.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
File
- src/
Form/ LingotekManagementForm.php, line 949 - Contains \Drupal\Lingotek\Form\LingotekManagementForm.
Class
- LingotekManagementForm
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function changeProfile(ContentEntityInterface $entity, $profile_id = NULL, &$context) {
$context['message'] = $this
->t('Changing Translation Profile for @type %label.', [
'@type' => $entity
->getEntityType()
->getLabel(),
'%label' => $entity
->label(),
]);
if ($profile = $this->lingotekConfiguration
->getEntityProfile($entity, FALSE) && $profile_id) {
try {
$this->lingotekConfiguration
->setProfile($entity, $profile_id, TRUE);
} catch (LingotekApiException $exception) {
drupal_set_message(t('The Tranlsation Profile change for @entity_type %title failed. Please try again.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
)), 'error');
}
}
else {
$bundleInfos = $this->entityManager
->getBundleInfo($entity
->getEntityTypeId());
drupal_set_message($this
->t('The @type %label has no profile assigned so it was not processed.', [
'@type' => $bundleInfos[$entity
->bundle()]['label'],
'%label' => $entity
->label(),
]), 'warning');
}
}