1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System Framework package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @author Steeve Andrian Salim |
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
13
|
|
|
|
14
|
|
|
namespace O2System\Framework\Libraries\Ui\Admin\Sidebar; |
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
17
|
|
|
|
18
|
|
|
use O2System\Framework\Libraries\Ui\Admin\Sidebar\Menu\UnorderedList; |
19
|
|
|
use O2System\Framework\Libraries\Ui\Element; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class Menu |
23
|
|
|
* @package O2System\Framework\Libraries\Ui\Admin\Sidebar |
24
|
|
|
*/ |
25
|
|
|
class Menu extends Element |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Menu::$list |
29
|
|
|
* |
30
|
|
|
* @var \O2System\Framework\Libraries\Ui\Admin\Sidebar\Menu\UnorderedList |
31
|
|
|
*/ |
32
|
|
|
public $list; |
33
|
|
|
|
34
|
|
|
// ------------------------------------------------------------------------ |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Code::__construct |
38
|
|
|
* |
39
|
|
|
* @param array $attributes |
40
|
|
|
*/ |
41
|
|
|
public function __construct(array $attributes = []) |
42
|
|
|
{ |
43
|
|
|
parent::__construct('div'); |
44
|
|
|
|
45
|
|
|
if (isset($attributes[ 'id' ])) { |
46
|
|
|
$this->entity->setEntityName($attributes[ 'id' ]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
if (count($attributes)) { |
50
|
|
|
foreach ($attributes as $name => $value) { |
51
|
|
|
$this->attributes->addAttribute($name, $value); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$this->attributes->addAttributeClass('sidebar-menu'); |
56
|
|
|
|
57
|
|
|
$this->list = new UnorderedList(); |
58
|
|
|
|
59
|
|
|
$this->childNodes->push($this->list); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// ------------------------------------------------------------------------ |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Menu::createTitle |
66
|
|
|
* |
67
|
|
|
* @param string $title |
68
|
|
|
* |
69
|
|
|
* @return \O2System\Framework\Libraries\Ui\Contents\Lists\Item |
70
|
|
|
*/ |
71
|
|
|
public function createTitle($title) |
72
|
|
|
{ |
73
|
|
|
$item = $this->list->createList($title); |
74
|
|
|
$item->attributes->addAttributeClass('menu-title'); |
75
|
|
|
|
76
|
|
|
return $item; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// ------------------------------------------------------------------------ |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Menu::createItem |
83
|
|
|
* |
84
|
|
|
* @param mixed $item |
85
|
|
|
*/ |
86
|
|
|
public function createItem($item) |
87
|
|
|
{ |
88
|
|
|
$item = $this->list->createList($item); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
} |