/
Item.php
148 lines (122 loc) · 2.92 KB
/
Item.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
namespace Concrete\Core\Application\UserInterface\Menu\Item;
use Concrete\Core\Package\Package;
class Item implements ItemInterface
{
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|null
*/
public $handle;
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|false|null
*/
public $pkgHandle;
/**
* @var \Concrete\Core\Application\UserInterface\Menu\Item\ControllerInterface|null
*/
protected $controller;
protected $linkAttributes = [];
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|null
*/
public $position;
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|null
*/
public $href;
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|null
*/
public $label;
/**
* @deprecated What's deprecated is the "public" part.
*
* @var string|null
*/
public $icon;
public function __construct($handle, $pkgHandle = false)
{
$this->handle = $handle;
$this->pkgHandle = $pkgHandle;
}
public function getHandle()
{
return $this->handle;
}
public function getLabel()
{
return $this->label;
}
public function setLabel($label)
{
$this->label = $label;
}
public function getPosition()
{
return $this->position;
}
public function getLinkAttributes()
{
return $this->linkAttributes;
}
public function setLinkAttributes($linkAttributes)
{
$this->linkAttributes = $linkAttributes;
}
public function setLink($href)
{
$this->href = $href;
}
public function getLink()
{
return $this->href;
}
public function setIcon($icon)
{
$this->icon = $icon;
}
public function getIcon()
{
return $this->icon;
}
public function setPosition($position)
{
$this->position = $position;
}
public function getPackageHandle()
{
return $this->pkgHandle;
}
public function getPackageObject()
{
return Package::getByHandle($this->getPackageHandle());
}
public function getController()
{
if ($this->controller === null) {
$handle = $this->getHandle();
$class = overrideable_core_class(
'MenuItem\\' . camelcase($handle) . '\\Controller',
DIRNAME_MENU_ITEMS . '/' . $handle . '/' . FILENAME_CONTROLLER,
$this->pkgHandle
);
$this->setController(\Core::make($class, ['item' => $this]));
}
return $this->controller;
}
public function setController(ControllerInterface $controller)
{
$this->controller = $controller;
$this->controller->setMenuItem($this);
}
}