1 | <?php |
||
34 | class MenuWidget extends Widget |
||
35 | { |
||
36 | /** |
||
37 | * Primary key name. |
||
38 | * @var string |
||
39 | */ |
||
40 | public $primaryKeyName = 'id'; |
||
41 | |||
42 | /** |
||
43 | * Relation key name. |
||
44 | * @var string |
||
45 | */ |
||
46 | public $parentKeyName = 'parentId'; |
||
47 | |||
48 | /** |
||
49 | * Main container html tag. |
||
50 | * @var string |
||
51 | */ |
||
52 | public $mainContainerTag = 'ul'; |
||
53 | |||
54 | /** |
||
55 | * Main container html options. |
||
56 | * @var array |
||
57 | */ |
||
58 | public $mainContainerOptions = []; |
||
59 | |||
60 | /** |
||
61 | * Sub main container html tag. |
||
62 | * @var string |
||
63 | */ |
||
64 | public $subMainContainerTag = 'ul'; |
||
65 | |||
66 | /** |
||
67 | * Sub main container html options. |
||
68 | * @var array |
||
69 | */ |
||
70 | public $subMainContainerOptions = []; |
||
71 | |||
72 | /** |
||
73 | * Item container html tag. |
||
74 | * @var string |
||
75 | */ |
||
76 | public $itemContainerTag = 'li'; |
||
77 | |||
78 | /** |
||
79 | * Item container html options. |
||
80 | * @var array |
||
81 | */ |
||
82 | public $itemContainerOptions = []; |
||
83 | |||
84 | /** |
||
85 | * Sub item container html tag. |
||
86 | * @var string |
||
87 | */ |
||
88 | public $subItemContainerTag = 'li'; |
||
89 | |||
90 | /** |
||
91 | * Sub item container html options. |
||
92 | * @var array |
||
93 | */ |
||
94 | public $subItemContainerOptions = []; |
||
95 | |||
96 | /** |
||
97 | * Item template to display widget elements. |
||
98 | * @var string |
||
99 | */ |
||
100 | public $itemTemplate; |
||
101 | |||
102 | /** |
||
103 | * Addition item template params. |
||
104 | * @var array |
||
105 | */ |
||
106 | public $itemTemplateParams = []; |
||
107 | |||
108 | /** |
||
109 | * Sub item template to display widget elements. |
||
110 | * @var string |
||
111 | */ |
||
112 | public $subItemTemplate; |
||
113 | |||
114 | /** |
||
115 | * Addition sub item template params. |
||
116 | * @var array |
||
117 | */ |
||
118 | public $subItemTemplateParams = []; |
||
119 | |||
120 | /** |
||
121 | * Data provider records. |
||
122 | * @var ActiveDataProvider |
||
123 | */ |
||
124 | private $dataProvider; |
||
125 | |||
126 | /** |
||
127 | * Starts the output widget of the multi level view records according with the menu type. |
||
128 | * @throws InvalidConfigException |
||
129 | */ |
||
130 | public function run() |
||
140 | |||
141 | /** |
||
142 | * Set data provider. |
||
143 | * @param ActiveDataProvider $dataProvider |
||
144 | */ |
||
145 | public function setDataProvider(ActiveDataProvider $dataProvider): void |
||
149 | |||
150 | /** |
||
151 | * Group records in to sub levels according with the relation to parent records. |
||
152 | * @param array $models |
||
153 | * @return array |
||
154 | */ |
||
155 | private function groupLevels(array $models): array |
||
179 | |||
180 | /** |
||
181 | * Base render. |
||
182 | * @param array $items |
||
183 | * @param bool $isSubLevel |
||
184 | * @return string |
||
185 | */ |
||
186 | private function renderItems(array $items, bool $isSubLevel = false): string |
||
215 | |||
216 | /** |
||
217 | * Check for configure. |
||
218 | * @throws InvalidConfigException |
||
219 | */ |
||
220 | private function checkConfiguration() |
||
234 | } |
||
235 |