File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 44
55namespace Hyde \Facades ;
66
7+ use function compact ;
8+
79/**
810 * General facade for navigation features.
911 */
1012class Navigation
1113{
12- //
14+ /**
15+ * Configuration helper method to define a new navigation item, with better IDE support.
16+ *
17+ * The returned array will then be used by the framework to create a new NavigationItem instance.
18+ *
19+ * @see https://hydephp.com/docs/2.x/navigation-api
20+ *
21+ * @param string<\Hyde\Support\Models\RouteKey>|string $destination Route key, or an external URI.
22+ * @param string|null $label If not provided, Hyde will try to get it from the route's connected page, or from the URL.
23+ * @param int|null $priority If not provided, Hyde will try to get it from the route or the default priority of 500.
24+ */
25+ public static function item (string $ destination , ?string $ label = null , ?int $ priority = null ): array
26+ {
27+ return compact ('destination ' , 'label ' , 'priority ' );
28+ }
1329}
Original file line number Diff line number Diff line change 44
55namespace Hyde \Framework \Testing \Unit \Facades ;
66
7+ use Hyde \Facades \Navigation ;
78use Hyde \Testing \UnitTestCase ;
89
910/**
1011 * @covers \Hyde\Facades\Navigation
1112 */
1213class NavigationFacadeTest extends UnitTestCase
1314{
14- //
15+ public function testItem (): void
16+ {
17+ $ item = Navigation::item ('home ' , 'Home ' , 100 );
18+
19+ $ this ->assertSame ([
20+ 'destination ' => 'home ' ,
21+ 'label ' => 'Home ' ,
22+ 'priority ' => 100 ,
23+ ], $ item );
24+ }
25+
26+ public function testItemWithOnlyDestination (): void
27+ {
28+ $ item = Navigation::item ('home ' );
29+
30+ $ this ->assertSame ([
31+ 'destination ' => 'home ' ,
32+ 'label ' => null ,
33+ 'priority ' => null ,
34+ ], $ item );
35+ }
1536}
You can’t perform that action at this time.
0 commit comments