Issue #2478151 by willzyx: Shortcuts to pages generated by views are not recognized as added to the shortcutset and are being added multiple times
parent
67f0d68fac
commit
d2c38c4539
|
@ -321,7 +321,7 @@ function shortcut_preprocess_page(&$variables) {
|
|||
$shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id()));
|
||||
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
|
||||
foreach ($shortcuts as $shortcut) {
|
||||
if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getParameters()->all()) {
|
||||
if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName()) {
|
||||
$shortcut_id = $shortcut->id();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,24 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
|
||||
$this->drupalGet('admin/structure');
|
||||
$this->assertNoLink('Cron', 'Shortcut link removed from different page');
|
||||
|
||||
$this->drupalGet('admin/people');
|
||||
|
||||
// Test the "Add to shortcuts" link for a page generated by views.
|
||||
$this->clickLink('Add to Default shortcuts');
|
||||
$this->assertText('Added a shortcut for People.');
|
||||
// Due to the structure of the markup in the link ::assertLink() doesn't
|
||||
// works here.
|
||||
$link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
|
||||
$this->assertTrue(!empty($link), 'Link Remove from Default shortcuts found.');
|
||||
|
||||
// Test the "Remove from shortcuts" link for a page generated by views.
|
||||
$this->clickLink('Remove from Default shortcuts');
|
||||
$this->assertText('The shortcut People has been deleted.');
|
||||
// Due to the structure of the markup in the link ::assertLink() doesn't
|
||||
// works here.
|
||||
$link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Add to Default shortcuts'));
|
||||
$this->assertTrue(!empty($link), 'Link Add to Default shortcuts found.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue