- $form['terms'][$key]['weight'] = [
- '#type' => 'weight',
- '#delta' => $delta,
- '#title' => $this->t('Weight for added term'),
- '#title_display' => 'invisible',
- '#default_value' => $term->getWeight(),
- '#attributes' => [
- 'class' => ['term-weight'],
- ],
- ];
- $operations = [
- 'edit' => [
- 'title' => $this->t('Edit'),
- 'query' => $destination,
- 'url' => $term->urlInfo('edit-form'),
- ],
- 'delete' => [
- 'title' => $this->t('Delete'),
- 'query' => $destination,
- 'url' => $term->urlInfo('delete-form'),
- ],
- ];
- if ($this->moduleHandler->moduleExists('content_translation') && content_translation_translate_access($term)->isAllowed()) {
- $operations['translate'] = [
- 'title' => $this->t('Translate'),
- 'query' => $destination,
- 'url' => $term->urlInfo('drupal:content-translation-overview'),
+ $update_access = $term->access('update', NULL, TRUE);
+ $change_weight_access = $change_weight_access->andIf($update_access);
+
+ if ($update_access->isAllowed()) {
+ $form['terms'][$key]['weight'] = [
+ '#type' => 'weight',
+ '#delta' => $delta,
+ '#title' => $this->t('Weight for added term'),
+ '#title_display' => 'invisible',
+ '#default_value' => $term->getWeight(),
+ '#attributes' => ['class' => ['term-weight']],
+ ];
+ }
+
+ if ($operations = $this->termListBuilder->getOperations($term)) {
+ $form['terms'][$key]['operations'] = [
+ '#type' => 'operations',
+ '#links' => $operations,