Skip to content

NavigationHooks

Navigation hooks for the Helper module.


  • Full name: \Drupal\helper\Hook\NavigationHooks

Properties

entityTypeManager

protected \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager

entityType

protected \Drupal\helper\EntityType $entityType

routeProvider

protected \Drupal\Core\Routing\RouteProviderInterface $routeProvider

routeBuilder

protected \Drupal\Core\Routing\RouteBuilderInterface $routeBuilder

Methods

__construct

NavigationHooks constructor.

public __construct(\Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager, \Drupal\helper\EntityType $entityType, \Drupal\Core\Routing\RouteProviderInterface $routeProvider, \Drupal\Core\Routing\RouteBuilderInterface $routeBuilder): mixed

Parameters:

Parameter Type Description
$entityTypeManager \Drupal\Core\Entity\EntityTypeManagerInterface
$entityType \Drupal\helper\EntityType
$routeProvider \Drupal\Core\Routing\RouteProviderInterface
$routeBuilder \Drupal\Core\Routing\RouteBuilderInterface

Implements hook_menu_links_discovered_alter().

public menuLinksDiscoveredAlter(array& $links): void

Adds the entity types and bundles in the navigation_create_links helper to the Navigation module's Create menu. An empty bundle list adds every bundle, sorted by label, under a link named after the entity type. A list of bundles adds only those that exist, directly under Create. Entity types that aren't installed or have no add-form link template are skipped.

Parameters:

Parameter Type Description
$links array

entityBundleCreate

Implements hook_entity_bundle_create().

public entityBundleCreate(string $entity_type_id, string $bundle): void

Parameters:

Parameter Type Description
$entity_type_id string
$bundle string

entityBundleDelete

Implements hook_entity_bundle_delete().

public entityBundleDelete(string $entity_type_id, string $bundle): void

Parameters:

Parameter Type Description
$entity_type_id string
$bundle string

Rebuilds the menu links when an entity type's Create links can change.

protected rebuildCreateLinks(string $entityTypeId): void

Parameters:

Parameter Type Description
$entityTypeId string
The entity type ID whose bundles changed.