Skip to content

Commit 3d83d9a

Browse files
committed
Docs for adding a sub menu with an existing builder
1 parent 895987c commit 3d83d9a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,21 @@ $subMenu = $mainMenuBuilder->getSubMenu('Super Sub Menu');
347347

348348
You can only do this after the main menu has been built, this is because the main menu builder takes care of building all sub menus.
349349

350+
If you have already have a configured menu builder you can just pass that to `addSubMenu` and be done:
351+
352+
```php
353+
354+
$subMenuBuilder = (new CliMenuBuilder)
355+
->setTitle('Behold the awesomeness')
356+
->addItem(/** **/);
357+
358+
$menu = (new CliMenuBuilder)
359+
->addSubMenu('Super Sub Menu', $subMenuBuilder)
360+
->build();
361+
```
362+
363+
In this case `addSubMenu` will return the main menu builder, not the sub menu builder.
364+
350365
#### Disabling Items & Sub Menus
351366

352367
In this example we are disabling certain items and a submenu but still having them shown in the output.

0 commit comments

Comments
 (0)