Commit 136112c9 authored by alexpott's avatar alexpott

Issue #2014617 by kfritsche, YesCT, tstoeckler: Fixed Unsaved menu links have...

Issue #2014617 by kfritsche, YesCT, tstoeckler: Fixed Unsaved menu links have the wrong bundle (always 'tools').
parent bf5c0ae2
......@@ -354,6 +354,11 @@ public function testMenuBundles() {
$moved_item = entity_load('menu_link', $item->id(), TRUE);
$this->assertNotEqual($moved_item->bundle(), $item->bundle(), 'Menu link bundle was changed');
$this->assertEqual($moved_item->bundle(), $menu->id(), 'Menu link bundle matches the menu');
$unsaved_item = entity_create('menu_link', array('menu_name' => $menu->id(), 'link_title' => $this->randomName(16), 'link_path' => '<front>'));
$this->assertEqual($unsaved_item->bundle(), $menu->id(), 'Unsaved menu link bundle matches the menu');
$this->assertEqual($unsaved_item->menu_name, $menu->id(), 'Unsaved menu link menu name matches the menu');
}
/**
......
......@@ -66,6 +66,18 @@ public function __construct($entity_type, array $entity_info, Connection $databa
}
}
/**
* {@inheritdoc}
*/
public function create(array $values) {
// The bundle of menu links being the menu name is not enforced but is the
// default behavior if no bundle is set.
if (!isset($values['bundle']) && isset($values['menu_name'])) {
$values['bundle'] = $values['menu_name'];
}
return parent::create($values);
}
/**
* {@inheritdoc}
*/
......
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