Issue #2257229 by marcingy | alasda: Cannot add external url or <front> as menu item.
parent
39d126b2d0
commit
4440d95b4a
|
@ -524,7 +524,7 @@ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {
|
|||
}
|
||||
|
||||
// Find the route_name.
|
||||
if (!isset($this->route_name)) {
|
||||
if (!$this->external && !isset($this->route_name)) {
|
||||
$url = Url::createFromPath($this->link_path);
|
||||
$this->route_name = $url->getRouteName();
|
||||
$this->route_parameters = $url->getRouteParameters();
|
||||
|
|
|
@ -395,6 +395,19 @@ class MenuTest extends MenuWebTestBase {
|
|||
// Verify in the database.
|
||||
$this->assertMenuLink($item1['mlid'], array('hidden' => 0));
|
||||
|
||||
// Add an external link.
|
||||
$item7 = $this->addMenuLink(0, 'http://drupal.org', $menu_name);
|
||||
$this->assertMenuLink($item7['mlid'], array('link_path' => 'http://drupal.org', 'external' => 1));
|
||||
|
||||
// Add <front> menu item.
|
||||
$item8 = $this->addMenuLink(0, '<front>', $menu_name);
|
||||
$this->assertMenuLink($item8['mlid'], array('link_path' => '<front>', 'external' => 1));
|
||||
$this->drupalGet('');
|
||||
$this->assertResponse(200);
|
||||
// Make sure we get routed correctly.
|
||||
$this->clickLink($item8['link_title']);
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Save menu links for later tests.
|
||||
$this->items[] = $item1;
|
||||
$this->items[] = $item2;
|
||||
|
|
Loading…
Reference in New Issue