Commit e023a689 authored by alexpott's avatar alexpott

Issue #791072 by Danny.Wouters, swentel, lz1irq, David_Rothstein, jbrown:...

Issue #791072 by Danny.Wouters, swentel, lz1irq, David_Rothstein, jbrown: Fixed Inline deletion of shortcut should not be confirmed.
parent ea833498
......@@ -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);
}
......
......@@ -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:
......
......@@ -9,6 +9,8 @@
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 @@ public function addForm(ShortcutSetInterface $shortcut_set) {
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>');
}
}
......@@ -118,7 +118,6 @@ public function testShortcutQuickLink() {
// 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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment