I want to programmatically create some admin menu items for my component and I'm most of the way there, but I can't seem to set the hierarchy for them. I am wanting three menu items - one as the parent menu item which expands to reveal two submenu items beneath it.
I am setting all of my values for each menu item in an instance of
Joomla\CMS\Table\Menu ($menu) and then calling
$menu->check() followed by
For my parent item I am setting
parent_id to 1 and
level to 1. When I use
$menu->store() to create it, I get the new ID that has been assigned to it and use that as the
parent_id for the 2 sub-menu items. I also set the
level for each of them to 2. Unfortunately the repositioning function that works out the lft and rgt menu items is resetting the parent_id and level values to zero for all three of my menu items, so I'm ending up with them all on the same level.
Any idea how I can get my values to persist? Or do I need to rethink how I'm doing this?