You are here

public function MenuLinksInfo::contextualLinksAlter in Form mode manager 8.2

Hide default entity contextualLinks.

This is an alter hook bridge.

We need to hide default contextual links to manage permission of, "Edit as default" contextual links.

array(
  'entityTypeId' => $entity
    ->id(),
);

Parameters

array $links: An associative array containing contextual links for the given $group, as described above. The array keys are used to build CSS class names for contextual links and must therefore be unique for each set of contextual links.

string $group: The group of contextual links being rendered.

array $route_parameters: The route parameters passed to each route_name of the contextual links. For example :.

See also

hook_contextual_links_alter()

File

src/MenuLinksInfo.php, line 78

Class

MenuLinksInfo
Manipulates Menus Links informations.

Namespace

Drupal\form_mode_manager

Code

public function contextualLinksAlter(array &$links, $group, array $route_parameters) {
  $available_entity_types = array_keys($this->formModeManager
    ->getAllFormModesDefinitions());
  foreach ($available_entity_types as $entity_type_id) {

    /** @var \Drupal\form_mode_manager\EntityRoutingMapBase $entity_handler_mapping */
    $entity_handler_mapping = $this->entityRoutingMap
      ->createInstance($entity_type_id, [
      'entityTypeId' => $entity_type_id,
    ]);
    $contextual_links_edit_id = $entity_handler_mapping
      ->getContextualLink('edit');
    if ($contextual_links_edit_id && isset($links[$contextual_links_edit_id])) {
      unset($links[$contextual_links_edit_id]);
    }
  }
}