You are here

public static function MenuLinkConfiguration::getAllIdentifiers in Configuration Management 7.2

Overrides Drupal\configuration\Config\Configuration::getAllIdentifiers().

Overrides Configuration::getAllIdentifiers

File

lib/Drupal/configuration/Config/MenuLinkConfiguration.php, line 97
Definition of Drupal\configuration\Config\FieldConfiguration.

Class

MenuLinkConfiguration

Namespace

Drupal\configuration\Config

Code

public static function getAllIdentifiers($component) {
  global $menu_admin;

  // Need to set this to TRUE in order to get menu links that the
  // current user may not have access to (i.e. user/login)
  $menu_admin = TRUE;

  // This is intentionally to get always the same number of menus for each
  // user that can manage configurations.
  global $user;
  $current_user = $user;

  // Run the next line as administrator.
  $user = user_load(1);
  $menu_links = menu_parent_options(menu_get_menus(), array(
    'mlid' => 0,
  ));

  // Back to the previous user.
  $user = $current_user;
  $options = array();
  foreach ($menu_links as $key => $name) {
    list($menu_name, $mlid) = explode(':', $key, 2);
    if ($mlid != 0) {
      $link = menu_link_load($mlid);
      $identifier = sha1(str_replace('-', '_', $link['menu_name']) . ':' . $link['link_path']);
      $options[$identifier] = "{$menu_name}: {$name}";
    }
  }
  $menu_admin = FALSE;
  return $options;
}