You are here

function menu_entity_index_entity_extra_field_info in Menu Entity Index 8

Implements hook_entity_extra_field_info().

File

./menu_entity_index.module, line 14
Main Menu Entity Index module file.

Code

function menu_entity_index_entity_extra_field_info() {
  $extra = [];
  $entity_type_manager = \Drupal::service('entity_type.manager');
  $tracker = \Drupal::service('menu_entity_index.tracker');
  foreach ($tracker
    ->getTrackedEntityTypes() as $entity_type_id) {
    $subtype_entity_type = $entity_type_manager
      ->getDefinition($entity_type_id)
      ->getBundleEntityType();
    $subtypes = $entity_type_manager
      ->getStorage($subtype_entity_type)
      ->loadMultiple();
    foreach ($subtypes as $machine_name => $subtype) {
      $extra[$entity_type_id][$subtype
        ->id()]['form']['menu_entity_index'] = [
        'label' => t('Menu Links'),
        'description' => t('Lists all menu links that reference this entity.'),
        'visible' => FALSE,
      ];
    }
  }
  return $extra;
}