How to set root of programmatically rendered menu I'm currently attempting to create a plugin where the user can choose what level of a menu to render regardless of what page they're on. I'm generating the form where the user can select the menu level here

public function blockForm($form, FormStateInterface $form_state) {
    $menu_name = 'main';

    $menu_tree = \Drupal::service('toolbar.menu_tree');

    $parameters = new \Drupal\Core\Menu\MenuTreeParameters();
    $tree       = $menu_tree-&gt;load($menu_name, $parameters);

    $manipulators = array(
        array('callable' =&gt; 'menu.default_tree_manipulators:checkAccess'),
        array('callable' =&gt; 'menu.default_tree_manipulators:generateIndexAndSort'),
        array('callable' =&gt; 'toolbar_menu_navigation_links'),
    );

    $tree = $menu_tree-&gt;transform($tree, $manipulators);
    $list = ['none' =&gt; $this-&gt;t('None')];
    foreach ($tree as $item) {
        $list += [$item-&gt;link-&gt;getPluginId()=&gt; $item-&gt;link-&gt;getTitle()];
        if ($item-&gt;hasChildren) {
            foreach ($item-&gt;subtree as $subitem) {
                foreach ($subitem-&gt;subtree as $subitem_child) {
                    $list += [$subitem-&gt;link-&gt;getPluginId() =&gt; '-'.$subitem-&gt;link-&gt;getTitle()];
                    foreach ($subitem-&gt;subtree as $sub_subitem) {
                        $list += [$sub_subitem-&gt;link-&gt;getPluginId()=&gt; '--'.$sub_subitem-&gt;link-&gt;getTitle()];
                    }
                }
            }
        }
    }

    $form        = [
        'menu'            =&gt; [
            '#type'          =&gt; 'select',
            '#title'         =&gt; $this-&gt;t('Top level of menu'),
            '#default_value' =&gt; $this-&gt;configuration['menu'],
            '#options'       =&gt; [
                $list,
            ],
        ],
    ];

    return $form;
}


This works, and the user can select the level of the menu they want, but I'm not sure what to use in order to render the menu at that level. I did see that I could get a plugin 

    $menu_name  = 'main';
    $menu       = $this-&gt;configuration['menu'];
    $menu_tree  = \Drupal::service('toolbar.menu_tree');

    $parameters = new \Drupal\Core\Menu\MenuTreeParameters();
    $tree = $menu_tree-&gt;load($menu_name, $parameters);

    $manipulators = array(
        array('callable' =&gt; 'menu.default_tree_manipulators:checkAccess'),
        array('callable' =&gt; 'menu.default_tree_manipulators:generateIndexAndSort'),
        array('callable' =&gt; 'toolbar_menu_navigation_links'),
    );

    $tree = $menu_tree-&gt;transform($tree, $manipulators);
    foreach ($tree as $item) {
        var_dump($item-&gt;hasChildren);
        if ($item-&gt;hasChildren) {
            var_dump($item-&gt;link-&gt;getTitle().' - '.$item-&gt;link-&gt;getPluginId());
            foreach ($item-&gt;subtree as $subitem) {
                var_dump($subitem-&gt;link-&gt;getTitle().' - '.$subitem-&gt;link-&gt;getPluginId());
                foreach ($subitem-&gt;subtree as $subitem_child) {
                    var_dump($subitem_child-&gt;link-&gt;getTitle().' - '.$subitem_child-&gt;link-&gt;getPluginId());
                    var_dump($subitem_child-&gt;link-&gt;getTitle().' - '.$subitem_child-&gt;link);
                }
            }
        }
    }


I have the pluginID of the selected in the form, but I'm not sure how to make any use of that. I tried using 
        $parameters->setRoot('818bf040-f12a-4915-835f-b9339eb7c828');

Where 818bf040-f12a-4915-835f-b9339eb7c828 in this case was the pluginid of the selected menu item, but that caused the menu to not return anything.

Is there a way to render a menu and set the root to a specified location inside that menu programmatically?
Try the following:

$parameters-&gt;setRoot('menu_link_content:818bf040-f12a-4915-835f-b9339eb7c828');