function ShortcutHooks::help

Implements hook_help().

File

core/modules/shortcut/src/Hook/ShortcutHooks.php, line 18

Class

ShortcutHooks
Hook implementations for shortcut.

Namespace

Drupal\shortcut\Hook

Code

public function help($route_name, RouteMatchInterface $route_match) {
    switch ($route_name) {
        case 'help.page.shortcut':
            $output = '<h2>' . t('About') . '</h2>';
            $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', [
                ':shortcut' => 'https://www.drupal.org/docs/8/core/modules/shortcut',
            ]) . '</p>';
            $output .= '<h2>' . t('Uses') . '</h2>';
            $output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
            $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', [
                ':shortcuts' => Url::fromRoute('entity.shortcut_set.collection')->toString(),
            ]) . '</dd>';
            $output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
            $output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>';
            $output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
            $output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Claro administration theme displays this link next to the page title, as a gray or yellow star. If you click on the gray star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>';
            $output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
            $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu link.', [
                ':blocks' => \Drupal::moduleHandler()->moduleExists('block') ? Url::fromRoute('block.admin_display')->toString() : '#',
                ':toolbar-help' => \Drupal::moduleHandler()->moduleExists('toolbar') ? Url::fromRoute('help.page', [
                    'name' => 'toolbar',
                ])->toString() : '#',
            ]) . '</dd>';
            $output .= '</dl>';
            return $output;
        case 'entity.shortcut_set.collection':
        case 'shortcut.set_add':
        case 'entity.shortcut_set.edit_form':
            $user = \Drupal::currentUser();
            if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) {
                $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', [
                    ':shortcut-link' => Url::fromRoute('shortcut.set_switch', [
                        'user' => $user->id(),
                    ])
                        ->toString(),
                ]) . '</p>';
                return $output;
            }
    }
}

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