function UserLocalTask::getDerivativeDefinitions

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/Derivative/UserLocalTask.php \Drupal\user\Plugin\Derivative\UserLocalTask::getDerivativeDefinitions()
  2. 10 core/modules/user/src/Plugin/Derivative/UserLocalTask.php \Drupal\user\Plugin\Derivative\UserLocalTask::getDerivativeDefinitions()

Overrides DeriverBase::getDerivativeDefinitions

File

core/modules/user/src/Plugin/Derivative/UserLocalTask.php, line 51

Class

UserLocalTask
Provides local task definitions for all entity bundles.

Namespace

Drupal\user\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];
    $entity_definitions = $this->entityTypeManager
        ->getDefinitions();
    foreach ($entity_definitions as $bundle_type_id => $bundle_entity_type) {
        if (!$bundle_entity_type->hasLinkTemplate('entity-permissions-form')) {
            continue;
        }
        if (!($entity_type_id = $bundle_entity_type->getBundleOf())) {
            continue;
        }
        $entity_type = $entity_definitions[$entity_type_id];
        if (!($base_route = $entity_type->get('field_ui_base_route'))) {
            continue;
        }
        $this->derivatives["permissions_{$bundle_type_id}"] = [
            'route_name' => "entity.{$bundle_type_id}.entity_permissions_form",
            'weight' => 10,
            'title' => $this->t('Manage permissions'),
            'base_route' => $base_route,
        ] + $base_plugin_definition;
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
}

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