@@ 82-98 (lines=17) @@ | ||
79 | * Add a submenu from an existing builder. Required a unique ID and the text. The text will be displayed as the |
|
80 | * item text in the parent menu. |
|
81 | */ |
|
82 | public function addSubMenuFromExistingBuilder(string $id, string $text, CliMenuBuilder $subMenuBuilder) : self |
|
83 | { |
|
84 | if (isset($this->subMenuBuilders[$id])) { |
|
85 | throw new \InvalidArgumentException( |
|
86 | sprintf('SubMenu with id: "%s" already exists. $id must be unique', $id) |
|
87 | ); |
|
88 | } |
|
89 | ||
90 | $this->menuItems[] = [ |
|
91 | 'type' => 'submenu-placeholder', |
|
92 | 'text' => $text, |
|
93 | 'id' => $id |
|
94 | ]; |
|
95 | ||
96 | $this->subMenuBuilders[$id] = $subMenuBuilder; |
|
97 | return $this; |
|
98 | } |
|
99 | ||
100 | private function buildSubMenus(array $items) : array |
|
101 | { |
|
@@ 60-76 (lines=17) @@ | ||
57 | * Add a submenu with a unique ID and the text. The text will be displayed as the item text |
|
58 | * in the parent menu. |
|
59 | */ |
|
60 | public function addSubMenu(string $id, string $text) : CliMenuBuilder |
|
61 | { |
|
62 | if (isset($this->subMenuBuilders[$id])) { |
|
63 | throw new \InvalidArgumentException( |
|
64 | sprintf('SubMenu with id: "%s" already exists. $id must be unique', $id) |
|
65 | ); |
|
66 | } |
|
67 | ||
68 | $this->menuItems[] = [ |
|
69 | 'type' => 'submenu-placeholder', |
|
70 | 'text' => $text, |
|
71 | 'id' => $id |
|
72 | ]; |
|
73 | ||
74 | $this->subMenuBuilders[$id] = CliMenuBuilder::newFromParent($this); |
|
75 | return $this->subMenuBuilders[$id]; |
|
76 | } |
|
77 | ||
78 | /** |
|
79 | * Add a submenu from an existing builder. Required a unique ID and the text. The text will be displayed as the |