Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserHooks.php

function UserHooks::entityOperation

Implements hook_entity_operation().

File

core/modules/user/src/Hook/UserHooks.php, line 497

Class

UserHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

public function entityOperation(EntityInterface $entity) {
    // Add Manage permissions link if this entity type defines the permissions
    // link template.
    if (!$entity->hasLinkTemplate('entity-permissions-form')) {
        return [];
    }
    $bundle_entity_type = $entity->bundle();
    $route = "entity.{$bundle_entity_type}.entity_permissions_form";
    if (empty(\Drupal::service('router.route_provider')->getRoutesByNames([
        $route,
    ]))) {
        return [];
    }
    $url = Url::fromRoute($route, [
        $bundle_entity_type => $entity->id(),
    ]);
    if (!$url->access()) {
        return [];
    }
    return [
        'manage-permissions' => [
            'title' => t('Manage permissions'),
            'weight' => 50,
            'url' => $url,
        ],
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal