You are here

public function ShortcutController::deleteShortcutLinkInline in Drupal 8

Same name and namespace in other branches
  1. 9 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 taxonomy.module.

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>');
}