function user_entity_operation

Same name in other branches
  1. 9 core/modules/user/user.module \user_entity_operation()
  2. 10 core/modules/user/user.module \user_entity_operation()

Implements hook_entity_operation().

File

core/modules/user/user.module, line 1225

Code

function user_entity_operation(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,
        ],
    ];
}

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