3 namespace Drupal\shortcut\Controller;
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\shortcut\ShortcutSetInterface;
7 use Drupal\shortcut\ShortcutInterface;
10 * Provides route responses for taxonomy.module.
12 class ShortcutController extends ControllerBase {
15 * Returns a form to add a new shortcut to a given set.
17 * @param \Drupal\shortcut\ShortcutSetInterface $shortcut_set
18 * The shortcut set this shortcut will be added to.
21 * The shortcut add form.
23 public function addForm(ShortcutSetInterface $shortcut_set) {
24 $shortcut = $this->entityManager()->getStorage('shortcut')->create(['shortcut_set' => $shortcut_set->id()]);
25 return $this->entityFormBuilder()->getForm($shortcut, 'add');
29 * Deletes the selected shortcut.
31 * @param \Drupal\shortcut\ShortcutInterface $shortcut
32 * The shortcut to delete.
34 * @return \Symfony\Component\HttpFoundation\RedirectResponse
35 * A redirect to the previous location or the front page when destination
38 public function deleteShortcutLinkInline(ShortcutInterface $shortcut) {
39 $label = $shortcut->label();
43 drupal_set_message($this->t('The shortcut %title has been deleted.', ['%title' => $label]));
45 catch (\Exception $e) {
46 drupal_set_message($this->t('Unable to delete the shortcut for %title.', ['%title' => $label]), 'error');
49 return $this->redirect('<front>');