You are here

public function VocabularyListBuilder::getDefaultOperations in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/src/VocabularyListBuilder.php \Drupal\taxonomy\VocabularyListBuilder::getDefaultOperations()
  2. 9 core/modules/taxonomy/src/VocabularyListBuilder.php \Drupal\taxonomy\VocabularyListBuilder::getDefaultOperations()

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

core/modules/taxonomy/src/VocabularyListBuilder.php, line 106

Class

VocabularyListBuilder
Defines a class to build a listing of taxonomy vocabulary entities.

Namespace

Drupal\taxonomy

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  if (isset($operations['edit'])) {
    $operations['edit']['title'] = t('Edit vocabulary');
  }
  if ($entity
    ->access('access taxonomy overview')) {
    $operations['list'] = [
      'title' => t('List terms'),
      'weight' => 0,
      'url' => $entity
        ->toUrl('overview-form'),
    ];
  }
  $taxonomy_term_access_control_handler = $this->entityTypeManager
    ->getAccessControlHandler('taxonomy_term');
  if ($taxonomy_term_access_control_handler
    ->createAccess($entity
    ->id())) {
    $operations['add'] = [
      'title' => t('Add terms'),
      'weight' => 10,
      'url' => Url::fromRoute('entity.taxonomy_term.add_form', [
        'taxonomy_vocabulary' => $entity
          ->id(),
      ]),
    ];
  }
  unset($operations['delete']);
  return $operations;
}