|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\CoreBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity; |
|
7
|
|
|
use Victoire\Bundle\WidgetBundle\Entity\Widget; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* The Entity proxy is the link between a view, a widget or any else with the BusinessEntity. |
|
11
|
|
|
* |
|
12
|
|
|
* @ORM\Table("vic_entity_proxy") |
|
13
|
|
|
* @ORM\Entity() |
|
14
|
|
|
*/ |
|
15
|
|
|
class EntityProxy |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var int |
|
19
|
|
|
* |
|
20
|
|
|
* @ORM\Column(name="id", type="integer") |
|
21
|
|
|
* @ORM\Id |
|
22
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $id; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
* |
|
29
|
|
|
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\WidgetBundle\Entity\Widget", mappedBy="entityProxy") |
|
30
|
|
|
* @ORM\OrderBy({"id" = "ASC"}) |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $widgets; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* id of the ressource (could be an integer, an hash...). |
|
36
|
|
|
* |
|
37
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $ressourceId; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var BusinessEntity |
|
43
|
|
|
* |
|
44
|
|
|
* @ORM\ManyToOne(targetEntity="\Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity") |
|
45
|
|
|
* @ORM\JoinColumn(name="business_entity_id", referencedColumnName="id", onDelete="CASCADE") |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $businessEntity; |
|
48
|
|
|
protected $entity; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* This is used to pass additionnal informations to the API call, like the format (eg. lite, full...) or to give some |
|
52
|
|
|
* filters (eg. ?color=red...) |
|
53
|
|
|
* @var array |
|
54
|
|
|
* |
|
55
|
|
|
* @ORM\Column(type="text", nullable=true) |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $additionnalProperties; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get id. |
|
61
|
|
|
* |
|
62
|
|
|
* @return int |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getId() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->id; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param int $id |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setId($id) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->id = $id; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Get the entity of the proxy. |
|
79
|
|
|
* |
|
80
|
|
|
* @throws \Exception |
|
81
|
|
|
* |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getEntity() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->entity; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Set the entity. |
|
91
|
|
|
* |
|
92
|
|
|
* @param $entity |
|
93
|
|
|
* @param $entityId |
|
94
|
|
|
* |
|
95
|
|
|
* @throws \Exception |
|
96
|
|
|
*/ |
|
97
|
|
|
public function setEntity($entity) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->entity = $entity; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Set widgets. |
|
104
|
|
|
* |
|
105
|
|
|
* @param array $widgets |
|
106
|
|
|
* |
|
107
|
|
|
* @return EntityProxy |
|
108
|
|
|
*/ |
|
109
|
|
|
public function setWidgets($widgets) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->widgets = $widgets; |
|
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
foreach ($widgets as $widget) { |
|
114
|
|
|
$widget->setView($this); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Get widgets. |
|
122
|
|
|
* |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getWidgets() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->widgets; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Add widget. |
|
132
|
|
|
* |
|
133
|
|
|
* @param Widget $widget |
|
134
|
|
|
*/ |
|
135
|
|
|
public function addWidget(Widget $widget) |
|
136
|
|
|
{ |
|
137
|
|
|
$this->widgets[] = $widget; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Remove widget. |
|
142
|
|
|
* |
|
143
|
|
|
* @param Widget $widget |
|
144
|
|
|
*/ |
|
145
|
|
|
public function removeWidget(Widget $widget) |
|
146
|
|
|
{ |
|
147
|
|
|
$this->widgets->remove($widget); |
|
|
|
|
|
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* has widget. |
|
152
|
|
|
* |
|
153
|
|
|
* @param Widget $widget |
|
154
|
|
|
* |
|
155
|
|
|
* @return bool |
|
156
|
|
|
*/ |
|
157
|
|
|
public function hasWidget(Widget $widget) |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->widgets->contains($widget); |
|
|
|
|
|
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return BusinessEntity |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getBusinessEntity() |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->businessEntity; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param BusinessEntity $businessEntity |
|
172
|
|
|
*/ |
|
173
|
|
|
public function setBusinessEntity($businessEntity) |
|
174
|
|
|
{ |
|
175
|
|
|
$this->businessEntity = $businessEntity; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return mixed |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getRessourceId() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->ressourceId; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param mixed $ressource |
|
|
|
|
|
|
188
|
|
|
*/ |
|
189
|
|
|
public function setRessourceId($ressourceId) |
|
190
|
|
|
{ |
|
191
|
|
|
$this->ressourceId = $ressourceId; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return array |
|
196
|
|
|
*/ |
|
197
|
|
|
public function getAdditionnalProperties() |
|
198
|
|
|
{ |
|
199
|
|
|
return unserialize($this->additionnalProperties); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @param array $additionnalProperties |
|
204
|
|
|
*/ |
|
205
|
|
|
public function setAdditionnalProperties($additionnalProperties) |
|
206
|
|
|
{ |
|
207
|
|
|
$this->additionnalProperties = serialize($additionnalProperties); |
|
|
|
|
|
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..