1 | <?php |
||
18 | class Menu { |
||
19 | use |
||
20 | Singleton; |
||
21 | const INIT_STATE_METHOD = 'init'; |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | public $section_items; |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | public $items; |
||
30 | |||
31 | protected function init () { |
||
35 | /** |
||
36 | * Get menu in HTML format |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | function get_menu () { |
||
50 | /** |
||
51 | * Render sections (automatically includes nested items) |
||
52 | * |
||
53 | * @param string $module |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | protected function render_sections ($module) { |
||
72 | /** |
||
73 | * Render items |
||
74 | * |
||
75 | * @param string $module |
||
76 | * @param string $base_href If passed - only nested elements for this base href will be rendered |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | protected function render_items ($module, $base_href = '') { |
||
99 | /** |
||
100 | * Add second-level item into menu |
||
101 | * |
||
102 | * All third-level items which start with the same `$href` will be inside this second-level menu item |
||
103 | * |
||
104 | * @param string $module |
||
105 | * @param string $title |
||
106 | * @param array $attributes |
||
107 | */ |
||
108 | function add_section_item ($module, $title, $attributes = []) { |
||
114 | /** |
||
115 | * Add third-level item into menu (second-level when there is corresponding section items) |
||
116 | * |
||
117 | * @param string $module |
||
118 | * @param string $title |
||
119 | * @param array $attributes |
||
120 | */ |
||
121 | function add_item ($module, $title, $attributes = []) { |
||
127 | } |
||
128 |