function ShortcutController::deleteShortcutLinkInline

Same name and namespace in other branches
  1. 8.9.x core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::deleteShortcutLinkInline()
  2. 10 core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::deleteShortcutLinkInline()
  3. 11.x core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::deleteShortcutLinkInline()

Deletes the selected shortcut.

Parameters

\Drupal\shortcut\ShortcutInterface $shortcut: The shortcut to delete.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect to the previous location or the front page when destination is not set.

1 string reference to 'ShortcutController::deleteShortcutLinkInline'
shortcut.routing.yml in core/modules/shortcut/shortcut.routing.yml
core/modules/shortcut/shortcut.routing.yml

File

core/modules/shortcut/src/Controller/ShortcutController.php, line 38

Class

ShortcutController
Provides route responses for <a href="/api/drupal/core%21modules%21taxonomy%21taxonomy.module/9" title="Enables the organization of content into categories." class="local">taxonomy.module</a>.

Namespace

Drupal\shortcut\Controller

Code

public function deleteShortcutLinkInline(ShortcutInterface $shortcut) {
    $label = $shortcut->label();
    try {
        $shortcut->delete();
        $this->messenger()
            ->addStatus($this->t('The shortcut %title has been deleted.', [
            '%title' => $label,
        ]));
    } catch (\Exception $e) {
        $this->messenger()
            ->addStatus($this->t('Unable to delete the shortcut for %title.', [
            '%title' => $label,
        ]), 'error');
    }
    return $this->redirect('<front>');
}

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