This question has been answered by fractalwolfe. See the first response.
$action = $modx->newObject('modAction');
$action->fromArray(array(
'id' => 1,
'namespace' => 'harbour',
'parent' => 0,
'controller' => 'index',
'haslayout' => true,
'lang_topics' => 'harbour:default',
'assets' => '',
),'',true,true);
$menus[1] = $modx->newObject('modMenu');
$menus[1]->fromArray(array(
'text' => 'harbour', // This value is used in the parent field of the submenu
'parent' => 'components',
'description' => 'harbour.menu_dashboard_desc',
'icon' => 'images/icons/plugin.gif',
'menuindex' => 0,
'params' => '',
'handler' => '',
),'',true,true);
$menus[1]->addOne($action);
$action = $modx->newObject('modAction');
$action->fromArray(array(
'id' => 1,
'namespace' => 'harbour',
'parent' => 0,
'controller' => 'index',
'haslayout' => true,
'lang_topics' => 'harbour:default',
'assets' => '',
),'',true,true);
$menus[2] = $modx->newObject('modMenu');
$menus[2]->fromArray(array(
'text' => 'harbour.menu_events',
'parent' => 'harbour', // This matches the text value of the parent
'description' => 'harbour.menu_events_desc',
'icon' => 'images/icons/plugin.gif',
'menuindex' => 0,
'params' => '&action=mgr/events',
'handler' => '',
),'',true,true);
$menus[2]->addOne($action);
return $menus;$menus = include $sources['data'].'transport.menu.php';
foreach ($menus as $menu) {
$vehicle = $builder->createVehicle($menus,array(
xPDOTransport::PRESERVE_KEYS => true,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'text',
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'Action' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => array ('namespace','controller'),
),
),
));
$builder->putVehicle($vehicle);
unset($menu, $vehicle);
}