You are here

function admin_menu_links_icon in Administration menu 8.3

Same name and namespace in other branches
  1. 6.3 admin_menu.inc \admin_menu_links_icon()
  2. 7.3 admin_menu.inc \admin_menu_links_icon()

Build icon menu links; mostly containing maintenance helpers.

See also

theme_admin_menu_links()

1 call to admin_menu_links_icon()
admin_menu_output in ./admin_menu.module
Build the administration menu output.

File

./admin_menu.inc, line 428
Menu builder functions for Administration menu.

Code

function admin_menu_links_icon() {
  $destination = \Drupal::service('redirect.destination')
    ->getAsArray();
  $links = [
    '#theme' => 'admin_menu_links',
    '#wrapper_attributes' => [
      'id' => 'admin-menu-icon',
    ],
    '#weight' => -100,
  ];
  $links['icon'] = [
    '#title' => theme('admin_menu_icon'),
    '#attributes' => [
      'class' => [
        'admin-menu-icon',
      ],
    ],
    '#href' => '<front>',
    '#options' => [
      'html' => TRUE,
    ],
  ];

  // Add link to manually run cron.
  $links['icon']['cron'] = [
    '#title' => t('Run cron'),
    '#weight' => 50,
    '#access' => user_access('administer site configuration'),
    '#href' => 'admin/reports/status/run-cron',
    '#options' => [
      'query' => $destination,
    ],
  ];

  // Add link to run update.php.
  $links['icon']['update'] = [
    '#title' => t('Run updates'),
    '#weight' => 50,
    // @see update_access_allowed()
    '#access' => $GLOBALS['user']->uid == 1 || !empty($GLOBALS['update_free_access']) || user_access('administer software updates'),
    '#href' => base_path() . 'update.php',
    '#options' => [
      'external' => TRUE,
    ],
  ];

  // Add link to drupal.org.
  $links['icon']['drupal.org'] = [
    '#title' => 'Drupal.org',
    '#weight' => 100,
    '#access' => user_access('display drupal links'),
    '#href' => 'http://drupal.org',
  ];

  // Add links to project issue queues.
  foreach (module_list() as $module) {
    $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info.yml');
    if (!isset($info['project']) || isset($links['icon']['drupal.org'][$info['project']])) {
      continue;
    }
    $links['icon']['drupal.org'][$info['project']] = [
      '#title' => t('@project issue queue', [
        '@project' => $info['name'],
      ]),
      '#weight' => $info['project'] == 'drupal' ? -10 : 0,
      '#href' => 'http://drupal.org/project/issues/' . $info['project'],
      '#options' => [
        'query' => [
          'version' => isset($info['core']) ? $info['core'] : 'All',
        ],
      ],
    ];
  }

  // Add items to flush caches.
  $links['icon']['flush-cache'] = [
    '#title' => t('Flush all caches'),
    '#weight' => 20,
    '#access' => user_access('flush caches'),
    '#href' => 'admin_menu/flush-cache',
    '#options' => [
      'query' => $destination + [
        'token' => drupal_get_token('admin_menu/flush-cache'),
      ],
    ],
  ];
  $caches = module_invoke_all('admin_menu_cache_info');
  foreach ($caches as $name => $cache) {
    $links['icon']['flush-cache'][$name] = [
      '#title' => $cache['title'],
      '#href' => 'admin_menu/flush-cache/' . $name,
      '#options' => [
        'query' => $destination + [
          'token' => drupal_get_token('admin_menu/flush-cache/' . $name),
        ],
      ],
    ];
  }

  // Add Devel module menu links.
  if (module_exists('devel')) {
    $devel_tree = menu_build_tree('devel');
    $devel_links = admin_menu_links_menu($devel_tree);
    if (element_get_visible_children($devel_links)) {
      $links['icon']['devel'] = [
        '#title' => t('Development'),
        '#weight' => 30,
      ] + $devel_links;
    }
  }
  return $links;
}