File tree Expand file tree Collapse file tree 5 files changed +27
-7
lines changed Expand file tree Collapse file tree 5 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public function getItemSchema(): Schema
43
43
'action ' => Expect::type ('string|array ' ),
44
44
'link ' => Expect::string (),
45
45
'include ' => Expect::type ('string|array ' ),
46
- 'data ' => Expect::arrayOf ('string ' , 'string ' ),
46
+ 'data ' => Expect::arrayOf ('mixed ' , 'string ' ),
47
47
'items ' => Expect::array (),
48
48
'visibility ' => Expect::from (new MenuVisibility ()),
49
49
]);
Original file line number Diff line number Diff line change @@ -32,20 +32,20 @@ public function getRealLink(): string;
32
32
public function getRealAbsoluteLink (): string ;
33
33
34
34
/**
35
- * @return array<string, string >
35
+ * @return array<string, mixed >
36
36
*/
37
37
public function getData (): array ;
38
38
39
39
/**
40
- * @param array<string, string > $data
40
+ * @param array<string, mixed > $data
41
41
*/
42
42
public function setData (array $ data ): void ;
43
43
44
44
public function hasDataItem (string $ name ): bool ;
45
45
46
- public function getDataItem (string $ name , ? string $ default = null ): ? string ;
46
+ public function getDataItem (string $ name , mixed $ default = null ): mixed ;
47
47
48
- public function addDataItem (string $ name , string $ value ): void ;
48
+ public function addDataItem (string $ name , mixed $ value ): void ;
49
49
50
50
/**
51
51
* @param string[] $include
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function hasDataItem(string $name): bool
29
29
return array_key_exists ($ name , $ this ->data );
30
30
}
31
31
32
- public function getDataItem (string $ name , ? string $ default = null ): ? string
32
+ public function getDataItem (string $ name , mixed $ default = null ): mixed
33
33
{
34
34
if (!array_key_exists ($ name , $ this ->data )) {
35
35
return $ default ;
@@ -38,7 +38,7 @@ public function getDataItem(string $name, ?string $default = null): ?string
38
38
return $ this ->data [$ name ];
39
39
}
40
40
41
- public function addDataItem (string $ name , string $ value ): void
41
+ public function addDataItem (string $ name , mixed $ value ): void
42
42
{
43
43
$ this ->data [$ name ] = $ value ;
44
44
}
Original file line number Diff line number Diff line change @@ -32,6 +32,21 @@ public function testDI(): void
32
32
Assert::type (MenuComponent::class, $ dic ->getService ('menu.component.factory ' )->create ('default ' ));
33
33
}
34
34
35
+ public function testDataItems (): void
36
+ {
37
+ $ dic = $ this ->createContainer ();
38
+
39
+ $ container = $ dic ->getService ('menu.container ' );
40
+ /** @var \Contributte\MenuControl\IMenu $menu */
41
+ $ menu = $ container ->getMenu ('default ' );
42
+
43
+ $ item = $ menu ->getItem ('Homepage ' );
44
+
45
+ Assert::type ('bool ' , $ item ->getDataItem ('bool ' ));
46
+ Assert::type ('string ' , $ item ->getDataItem ('icon ' ));
47
+ Assert::type ('array ' , $ item ->getDataItem ('structured ' ));
48
+ }
49
+
35
50
public function testRender (): void
36
51
{
37
52
$ dic = $ this ->createContainer ();
Original file line number Diff line number Diff line change 22
22
items :
23
23
Category :
24
24
action : Category:default
25
+ data :
26
+ icon : fa fa-home
27
+ bool : true
28
+ structured :
29
+ key : value
You can’t perform that action at this time.
0 commit comments