function TaxonomyHooks::entityOperation

Same name and namespace in other branches
  1. 11.x core/modules/taxonomy/src/Hook/TaxonomyHooks.php \Drupal\taxonomy\Hook\TaxonomyHooks::entityOperation()

Implements hook_entity_operation().

Attributes

#[Hook('entity_operation')]

File

core/modules/taxonomy/src/Hook/TaxonomyHooks.php, line 97

Class

TaxonomyHooks
Hook implementations for taxonomy.

Namespace

Drupal\taxonomy\Hook

Code

public function entityOperation(EntityInterface $term) : array {
  $operations = [];
  if ($term instanceof Term && $term->access('create')) {
    $operations['add-child'] = [
      'title' => $this->t('Add child'),
      'weight' => 10,
      'url' => Url::fromRoute('entity.taxonomy_term.add_form', [
        'taxonomy_vocabulary' => $term->bundle(),
      ], [
        'query' => [
          'parent' => $term->id(),
        ],
      ]),
    ];
  }
  return $operations;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.