|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\WidgetMapBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* |
|
7
|
|
|
*/ |
|
8
|
|
|
class Slot |
|
9
|
|
|
{ |
|
10
|
|
|
//the id |
|
11
|
|
|
protected $id = null; |
|
12
|
|
|
protected $widgetMaps = null; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Constructor. |
|
16
|
|
|
*/ |
|
17
|
|
|
public function __construct() |
|
18
|
|
|
{ |
|
19
|
|
|
$this->widgetMaps = []; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Get the id. |
|
24
|
|
|
* |
|
25
|
|
|
* @return string The id |
|
26
|
|
|
*/ |
|
27
|
|
|
public function getId() |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->id; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Set the id. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $id |
|
36
|
|
|
*/ |
|
37
|
|
|
public function setId($id) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->id = $id; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Set the widget maps for this slot. |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $widgetMaps |
|
46
|
|
|
*/ |
|
47
|
|
|
public function setWidgetMaps($widgetMaps) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->widgetMaps = $widgetMaps; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get the widget maps. |
|
54
|
|
|
* |
|
55
|
|
|
* @return WidgetMap[] The widget maps |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getWidgetMaps() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->widgetMaps; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Add a widget map to the list of widget maps. |
|
64
|
|
|
* |
|
65
|
|
|
* @param WidgetMap $widgetMap |
|
66
|
|
|
*/ |
|
67
|
|
|
public function addWidgetMap(WidgetMap $widgetMap) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->widgetMaps[] = $widgetMap; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Update the given widgetMap. |
|
74
|
|
|
* |
|
75
|
|
|
* @param WidgetMap $widgetMap |
|
76
|
|
|
* |
|
77
|
|
|
* @return Slot |
|
78
|
|
|
*/ |
|
79
|
|
|
public function updateWidgetMap($widgetMap) |
|
80
|
|
|
{ |
|
81
|
|
|
//parse all widfgetMaps |
|
82
|
|
|
foreach ($this->widgetMaps as $key => $_widgetMap) { |
|
83
|
|
|
//if this the widgetMap we are looking for |
|
84
|
|
|
if ($_widgetMap->getWidgetId() === $widgetMap->getWidgetId()) { |
|
|
|
|
|
|
85
|
|
|
$this->widgetMaps[$key] = $widgetMap; |
|
86
|
|
|
//there no need to continue, we found the slot |
|
87
|
|
|
break; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return $this; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Get the widget map by the widget id. |
|
96
|
|
|
* |
|
97
|
|
|
* @param int $widgetId |
|
98
|
|
|
* |
|
99
|
|
|
* @return WidgetMap |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getWidgetMapByWidgetId($widgetId) |
|
102
|
|
|
{ |
|
103
|
|
|
$widgetMap = null; |
|
104
|
|
|
|
|
105
|
|
|
$widgetMaps = $this->widgetMaps; |
|
106
|
|
|
|
|
107
|
|
|
//parse the widgets maps |
|
108
|
|
|
foreach ($widgetMaps as $wm) { |
|
109
|
|
|
if ($wm->getWidgetId() === $widgetId) { |
|
110
|
|
|
$widgetMap = $wm; |
|
111
|
|
|
//entity found, there is no need to continue |
|
112
|
|
|
break; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
return $widgetMap; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Remove the widget map from the slot. |
|
121
|
|
|
* |
|
122
|
|
|
* @param WidgetMap $widgetMap |
|
123
|
|
|
*/ |
|
124
|
|
|
public function removeWidgetMap(WidgetMap $widgetMap) |
|
125
|
|
|
{ |
|
126
|
|
|
$widgetMaps = $this->widgetMaps; |
|
127
|
|
|
|
|
128
|
|
|
//parse the widgets maps |
|
129
|
|
|
foreach ($widgetMaps as $index => $wm) { |
|
130
|
|
|
if ($wm->getWidgetId() === $widgetMap->getWidgetId()) { |
|
|
|
|
|
|
131
|
|
|
unset($this->widgetMaps[$index]); |
|
132
|
|
|
//entity found, there is no need to continue |
|
133
|
|
|
break; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.