File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 88###### 2025-XX-YY
99
1010- Added PHP 8.4 support
11+ - Added the ` clear() ` method to the menu
1112
1213### 1.11.0
1314###### 2024-03-12
Original file line number Diff line number Diff line change @@ -102,6 +102,12 @@ public function removeItem(string $name, $removeChildren = true)
102102 return $ this ->items ->remove ($ name );
103103 }
104104
105+ /** Remove all menu items from the menu */
106+ public function clear (): void
107+ {
108+ $ this ->items = new ItemCollection ();
109+ }
110+
105111 /**
106112 * Returns menu item by name
107113 *
Original file line number Diff line number Diff line change @@ -118,4 +118,17 @@ public function testAttributesAreProperlyRendered()
118118 $ this ->menu ->render ('ul ' )
119119 );
120120 }
121+
122+ public function testItCanDeleteAllMenuItems ()
123+ {
124+ /** @var Menu $menu */
125+ $ menu = \Menu::create ('menu2 ' );
126+ $ menu ->addItem ('home ' , 'Home ' , '/ ' );
127+ $ menu ->addItem ('about ' , 'About ' , '/about ' );
128+ $ menu ->addItem ('contact ' , 'Contact ' , '/contact ' );
129+
130+ $ this ->assertCount (3 , $ menu ->items );
131+ $ menu ->clear ();
132+ $ this ->assertCount (0 , $ menu ->items );
133+ }
121134}
You can’t perform that action at this time.
0 commit comments