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
|
|
|
* @var array |
52
|
|
|
* |
53
|
|
|
* @ORM\Column(type="text", nullable=true) |
54
|
|
|
*/ |
55
|
|
|
protected $additionnalProperties; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get id. |
59
|
|
|
* |
60
|
|
|
* @return int |
61
|
|
|
*/ |
62
|
|
|
public function getId() |
63
|
|
|
{ |
64
|
|
|
return $this->id; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param int $id |
69
|
|
|
*/ |
70
|
|
|
public function setId($id) |
71
|
|
|
{ |
72
|
|
|
$this->id = $id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get the entity of the proxy. |
77
|
|
|
* |
78
|
|
|
* @throws \Exception |
79
|
|
|
* |
80
|
|
|
* @return mixed |
81
|
|
|
*/ |
82
|
|
|
public function getEntity() |
83
|
|
|
{ |
84
|
|
|
return $this->entity; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Set the entity. |
89
|
|
|
* |
90
|
|
|
* @param $entity |
91
|
|
|
* @param $entityId |
92
|
|
|
* |
93
|
|
|
* @throws \Exception |
94
|
|
|
*/ |
95
|
|
|
public function setEntity($entity) |
96
|
|
|
{ |
97
|
|
|
$this->entity = $entity; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Set widgets. |
102
|
|
|
* |
103
|
|
|
* @param array $widgets |
104
|
|
|
* |
105
|
|
|
* @return EntityProxy |
106
|
|
|
*/ |
107
|
|
|
public function setWidgets($widgets) |
108
|
|
|
{ |
109
|
|
|
$this->widgets = $widgets; |
|
|
|
|
110
|
|
|
|
111
|
|
|
foreach ($widgets as $widget) { |
112
|
|
|
$widget->setView($this); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Get widgets. |
120
|
|
|
* |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getWidgets() |
124
|
|
|
{ |
125
|
|
|
return $this->widgets; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Add widget. |
130
|
|
|
* |
131
|
|
|
* @param Widget $widget |
132
|
|
|
*/ |
133
|
|
|
public function addWidget(Widget $widget) |
134
|
|
|
{ |
135
|
|
|
$this->widgets[] = $widget; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Remove widget. |
140
|
|
|
* |
141
|
|
|
* @param Widget $widget |
142
|
|
|
*/ |
143
|
|
|
public function removeWidget(Widget $widget) |
144
|
|
|
{ |
145
|
|
|
$this->widgets->remove($widget); |
|
|
|
|
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* has widget. |
150
|
|
|
* |
151
|
|
|
* @param Widget $widget |
152
|
|
|
* |
153
|
|
|
* @return bool |
154
|
|
|
*/ |
155
|
|
|
public function hasWidget(Widget $widget) |
156
|
|
|
{ |
157
|
|
|
return $this->widgets->contains($widget); |
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return BusinessEntity |
162
|
|
|
*/ |
163
|
|
|
public function getBusinessEntity() |
164
|
|
|
{ |
165
|
|
|
return $this->businessEntity; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param BusinessEntity $businessEntity |
170
|
|
|
*/ |
171
|
|
|
public function setBusinessEntity($businessEntity) |
172
|
|
|
{ |
173
|
|
|
$this->businessEntity = $businessEntity; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return mixed |
178
|
|
|
*/ |
179
|
|
|
public function getRessourceId() |
180
|
|
|
{ |
181
|
|
|
return $this->ressourceId; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @param mixed $ressource |
|
|
|
|
186
|
|
|
*/ |
187
|
|
|
public function setRessourceId($ressourceId) |
188
|
|
|
{ |
189
|
|
|
$this->ressourceId = $ressourceId; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return array |
194
|
|
|
*/ |
195
|
|
|
public function getAdditionnalProperties() |
196
|
|
|
{ |
197
|
|
|
return unserialize($this->additionnalProperties); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param array $additionnalProperties |
202
|
|
|
*/ |
203
|
|
|
public function setAdditionnalProperties($additionnalProperties) |
204
|
|
|
{ |
205
|
|
|
$this->additionnalProperties = serialize($additionnalProperties); |
|
|
|
|
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
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..