summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-09-08 16:48:41 (GMT)
committerAlex Pott2014-09-08 16:48:41 (GMT)
commite023a689a972c1b21c4e0f9ae4121802e5111fb3 (patch)
tree1e102dc12fd516a8b0de376ef8ae554aa0561395
parentea8334982eda6810e67ef5a4f8d3704695e8d500 (diff)
Issue #791072 by Danny.Wouters, swentel, lz1irq, David_Rothstein, jbrown: Fixed Inline deletion of shortcut should not be confirmed.
-rw-r--r--core/modules/shortcut/shortcut.module2
-rw-r--r--core/modules/shortcut/shortcut.routing.yml8
-rw-r--r--core/modules/shortcut/src/Controller/ShortcutController.php26
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutLinksTest.php1
4 files changed, 35 insertions, 2 deletions
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index be1d027..9dc7d5a 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -359,7 +359,7 @@ function shortcut_preprocess_page(&$variables) {
else {
$query['id'] = $shortcut_id;
$link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->label())) : t('Remove from shortcuts');
- $route_name = 'entity.shortcut.delete_form';
+ $route_name = 'entity.shortcut.link_delete_inline';
$route_parameters = array('shortcut' => $shortcut_id);
}
diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml
index 90752cd..6a892bd 100644
--- a/core/modules/shortcut/shortcut.routing.yml
+++ b/core/modules/shortcut/shortcut.routing.yml
@@ -62,6 +62,14 @@ entity.shortcut.canonical:
requirements:
_entity_access: 'shortcut.update'
+entity.shortcut.link_delete_inline:
+ path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete-inline'
+ defaults:
+ _controller: 'Drupal\shortcut\Controller\ShortcutController::deleteShortcutLinkInline'
+ requirements:
+ _entity_access: 'shortcut.delete'
+ _csrf_token: 'TRUE'
+
entity.shortcut.delete_form:
path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete'
defaults:
diff --git a/core/modules/shortcut/src/Controller/ShortcutController.php b/core/modules/shortcut/src/Controller/ShortcutController.php
index 943caa0..85371de 100644
--- a/core/modules/shortcut/src/Controller/ShortcutController.php
+++ b/core/modules/shortcut/src/Controller/ShortcutController.php
@@ -9,6 +9,8 @@ namespace Drupal\shortcut\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\shortcut\ShortcutSetInterface;
+use Drupal\shortcut\ShortcutInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides route responses for taxonomy.module.
@@ -30,4 +32,28 @@ class ShortcutController extends ControllerBase {
return $this->entityFormBuilder()->getForm($shortcut, 'add');
}
+ /**
+ * Deletes the selected shortcut.
+ *
+ * @param \Drupal\shortcut\ShortcutInterface $shortcut
+ * The shortcut to delete.
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ * A redirect to the previous location or the front page when destination
+ * is not set.
+ */
+ public function deleteShortcutLinkInline(ShortcutInterface $shortcut) {
+ $label = $shortcut->label();
+
+ try {
+ $shortcut->delete();
+ drupal_set_message($this->t('The shortcut %title has been deleted.', array('%title' => $label)));
+ }
+ catch (\Exception $e) {
+ drupal_set_message($this->t('Unable to delete the shortcut for %title.', array('%title' => $label)));
+ }
+
+ return $this->redirect('<front>');
+ }
+
}
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index 85c7253..2b4c731 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -118,7 +118,6 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Test the "Remove from shortcuts" link.
$this->clickLink('Cron');
$this->clickLink('Remove from Default shortcuts');
- $this->drupalPostForm(NULL, array(), 'Delete');
$this->assertText('The shortcut Cron has been deleted.');
$this->assertNoLink('Cron', 'Shortcut link removed from page');