function _environment_indicator_switcher_menu in Environment Indicator 8.2
Same name and namespace in other branches
- 7.2 environment_indicator.module \_environment_indicator_switcher_menu()
Helper function to generate a menu with the environments to switch to.
1 call to _environment_indicator_switcher_menu()
- environment_indicator_toolbar in ./
environment_indicator.module - Implements hook_toolbar().
File
- ./
environment_indicator.module, line 314 - Module implementation file.
Code
function _environment_indicator_switcher_menu() {
$element = array(
'#heading' => t('Environment indicator'),
'toolbar_indicators' => array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'toolbar-menu-environment-indicator',
),
),
'indicator_menu' => array(
'#sorted' => TRUE,
'#theme_wrappers' => array(
'menu_tree',
),
),
),
);
$environments = environment_indicator_get_all(TRUE);
if (empty($environments)) {
$element['toolbar_indicators']['indicator_menu']['empty'] = array(
'#theme' => 'menu_link',
'#title' => '- ' . t('There are no other environments available.') . ' -',
'#href' => current_path(),
'#localized_options' => array(
'html' => TRUE,
),
'#below' => array(),
'#attributes' => array(
'class' => array(
'leaf',
),
),
);
}
$current_environment = environment_indicator_get_active();
foreach ($environments as $machine => $environment) {
if ($machine != $current_environment['machine']) {
$element['toolbar_indicators']['indicator_menu'][$environment
->id()] = array(
'#theme' => 'menu_link',
'#title' => t('Open in: %name', array(
'%name' => $environment
->label(),
)),
'#href' => 'http://' . $environment
->get('regexurl') . '/' . current_path(),
'#localized_options' => array(
'html' => TRUE,
),
'#below' => array(),
'#attributes' => array(
'class' => array(
'leaf',
),
),
);
}
}
return $element;
}