You are here

function nodeorder_entity_operation in Node Order 8

Implements hook_entity_operation().

Related topics

File

./nodeorder.module, line 37
Nodeorder module.

Code

function nodeorder_entity_operation(EntityInterface $entity) {
  $operations = [];
  if ($entity instanceof Term) {

    /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
    $nodeorder_manager = \Drupal::service('nodeorder.manager');
    if ($nodeorder_manager
      ->vocabularyIsOrderable($entity
      ->getVocabularyId())) {
      $operations['order'] = [
        'title' => t('Order'),
        'query' => \Drupal::destination()
          ->getAsArray(),
        'url' => Url::fromRoute('nodeorder.admin_order', [
          'taxonomy_term' => $entity
            ->id(),
        ]),
        'weight' => 20,
      ];
    }
  }
  return $operations;
}