Issue #2257229 by marcingy | alasda: Cannot add external url or <front> as menu item.

8.0.x
webchick 2014-05-06 11:49:41 -07:00
parent 39d126b2d0
commit 4440d95b4a
2 changed files with 14 additions and 1 deletions

View File

@ -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();

View File

@ -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;