1 | <?php |
||
28 | class MenuWidget extends Widget |
||
29 | { |
||
30 | /** |
||
31 | * Primary key name. |
||
32 | * @var string |
||
33 | */ |
||
34 | public $primaryKeyName = 'id'; |
||
35 | |||
36 | /** |
||
37 | * Relation key name. |
||
38 | * @var string |
||
39 | */ |
||
40 | public $parentKeyName = 'parentId'; |
||
41 | |||
42 | /** |
||
43 | * Main container html tag. |
||
44 | * @var string |
||
45 | */ |
||
46 | public $mainContainerTag = 'ul'; |
||
47 | |||
48 | /** |
||
49 | * Main container html options. |
||
50 | * @var array |
||
51 | */ |
||
52 | public $mainContainerOptions = []; |
||
53 | |||
54 | /** |
||
55 | * Item container html tag. |
||
56 | * @var string |
||
57 | */ |
||
58 | public $itemContainerTag = 'li'; |
||
59 | |||
60 | /** |
||
61 | * Item container html options. |
||
62 | * @var array |
||
63 | */ |
||
64 | public $itemContainerOptions = []; |
||
65 | |||
66 | /** |
||
67 | * Item template to display widget elements. |
||
68 | * @var string |
||
69 | */ |
||
70 | public $itemTemplate; |
||
71 | |||
72 | /** |
||
73 | * Addition item template params. |
||
74 | * @var array |
||
75 | */ |
||
76 | public $itemTemplateParams = []; |
||
77 | |||
78 | /** |
||
79 | * Data provider records. |
||
80 | * @var ActiveDataProvider |
||
81 | */ |
||
82 | private $dataProvider; |
||
83 | |||
84 | /** |
||
85 | * Starts the output widget of the multi level view records according with the menu type. |
||
86 | * @throws InvalidConfigException |
||
87 | */ |
||
88 | public function run() |
||
104 | |||
105 | /** |
||
106 | * Set data provider. |
||
107 | * @param ActiveDataProvider $dataProvider |
||
108 | */ |
||
109 | public function setDataProvider(ActiveDataProvider $dataProvider): void |
||
113 | |||
114 | /** |
||
115 | * Group records in to sub levels according with the relation to parent records. |
||
116 | * @param array $models |
||
117 | * @return array |
||
118 | */ |
||
119 | private function groupLevels(array $models): array |
||
143 | |||
144 | /** |
||
145 | * Base render. |
||
146 | * @param array $items |
||
147 | * @return string |
||
148 | */ |
||
149 | private function renderItems(array $items): string |
||
171 | } |
||
172 |