function settings_tray_contextual_links_view_alter

Same name in other branches
  1. 8.9.x core/modules/settings_tray/settings_tray.module \settings_tray_contextual_links_view_alter()
  2. 10 core/modules/settings_tray/settings_tray.module \settings_tray_contextual_links_view_alter()
  3. 11.x core/modules/settings_tray/settings_tray.module \settings_tray_contextual_links_view_alter()

Implements hook_contextual_links_view_alter().

Change Configure Blocks into off_canvas links.

File

core/modules/settings_tray/settings_tray.module, line 41

Code

function settings_tray_contextual_links_view_alter(&$element, $items) {
    if (isset($element['#links']['settings-trayblock-configure'])) {
        // Place settings_tray link first.
        $settings_tray_link = $element['#links']['settings-trayblock-configure'];
        unset($element['#links']['settings-trayblock-configure']);
        $element['#links'] = [
            'settings-trayblock-configure' => $settings_tray_link,
        ] + $element['#links'];
        // If this is content block change title to avoid duplicate "Quick Edit".
        if (isset($element['#links']['block-contentblock-edit'])) {
            $element['#links']['settings-trayblock-configure']['title'] = t('Quick edit settings');
        }
        $element['#attached']['library'][] = 'core/drupal.dialog.off_canvas';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.