function tmgmt_local_menu_links_discovered_alter

Implements hook_menu_links_discovered_alter().

File

translators/tmgmt_local/tmgmt_local.module, line 104
Main module file for the local translation module.

Code

function tmgmt_local_menu_links_discovered_alter(&$links) {

  // Display the menu item if one of the default past event views exists.
  $view = NULL;
  if ($view = Views::getView('tmgmt_local_manage_translate_task')) {
    $view
      ->initDisplay();
    $links['tmgmt_local_manage_translate_task'] = [
      'title' => new TranslatableMarkup('Manage tasks'),
      'description' => new TranslatableMarkup('Overview the local translation process and manage the tasks.'),
      'route_name' => $view
        ->getUrl(NULL, 'unassigned')
        ->getRouteName(),
      'parent' => 'tmgmt.admin_tmgmt',
      'menu_name' => 'admin',
      'weight' => 50,
    ];
  }
  if ($view = Views::getView('tmgmt_local_task_overview')) {
    $view
      ->initDisplay();
    $links['tmgmt_local_task_overview'] = [
      'title' => new TranslatableMarkup('Translate'),
      'description' => new TranslatableMarkup('Perform task translations.'),
      'route_name' => $view
        ->getUrl(NULL, 'unassigned')
        ->getRouteName(),
      'parent' => 'tmgmt.admin_tmgmt',
      'menu_name' => 'admin',
      'weight' => 55,
    ];
    if (!\Drupal::config('tmgmt_local.settings')
      ->get('use_admin_theme')) {
      $links['tmgmt_local_task_overview']['menu_name'] = 'account';
      unset($links['tmgmt_local_task_overview']['parent']);
      unset($links['tmgmt_local_task_overview']['weight']);
    }
  }
}