entity_references_map-1.0.0-alpha2/entity_references_map.module

entity_references_map.module
<?php

/**
 * @file
 * Entity References Map module functionality.
 */

use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * Implements hook_entity_operation().
 */
function entity_references_map_entity_operation(EntityInterface $entity): array {
  $operations = [];
  $user = Drupal::currentUser();

  // Adding node operation link.
  if (($entity instanceof Node)
    && ($user->hasPermission('view any node map page')
      || $user->hasPermission("view node map page in {$entity->getType()}"))
    && \Drupal::configFactory()->getEditable('entity_references_map.config')->get($entity->getType())) {
    $operations['map'] = [
      'title' => t('Map'),
      'weight' => 100,
      'url' => URL::fromRoute('entity.node.map_page', ['node' => $entity->id()]),
    ];
  }

  // Adding node_type operation link.
  if ($entity instanceof NodeType) {
    $operations['map'] = [
      'title' => t('Manage reference map'),
      'weight' => 60,
      'url' => URL::fromRoute('entity.node_type.entity_references_map-config', ['node_type' => $entity->id()]),
    ];
  }
  return $operations;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc