1
|
|
|
<?php |
2
|
|
|
namespace Test\TestBundle\Entity; |
3
|
|
|
|
4
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
5
|
|
|
use Tpg\ExtjsBundle\Annotation as Extjs; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use JMS\Serializer\Annotation as JMS; |
8
|
|
|
use \Test\TestBundle\Entity\CarOwner; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @Extjs\Model |
12
|
|
|
* @Extjs\ModelProxy("/mycars") |
13
|
|
|
* @ORM\Entity |
14
|
|
|
* @ORM\Table(name="car") |
15
|
|
|
*/ |
16
|
|
|
class Car { |
17
|
|
|
/** |
18
|
|
|
* @ORM\Id |
19
|
|
|
* @ORM\Column(type="integer") |
20
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
21
|
|
|
* @JMS\Type("integer") |
22
|
|
|
*/ |
23
|
|
|
protected $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ORM\Column(type="string") |
27
|
|
|
* @JMS\Type("string") |
28
|
|
|
*/ |
29
|
|
|
protected $name; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\Column(type="string", name="plate_number") |
33
|
|
|
* @JMS\Type("string") |
34
|
|
|
*/ |
35
|
|
|
protected $plateNumber; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @ORM\Column(type="string", nullable=true) |
39
|
|
|
* @JMS\Type("string") |
40
|
|
|
* @JMS\Groups({"post"}) |
41
|
|
|
*/ |
42
|
|
|
protected $password; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\ManyToOne(targetEntity="Test\TestBundle\Entity\CarOwner", inversedBy="cars", cascade={"persist"}) |
46
|
|
|
* @ORM\JoinColumn(name="car_owner_id", referencedColumnName="id") |
47
|
|
|
* @JMS\Type("Test\TestBundle\Entity\CarOwner") |
48
|
|
|
*/ |
49
|
|
|
protected $carOwner; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\ManyToOne(targetEntity="Test\TestBundle\Entity\Car", inversedBy="relatedCars", cascade={"persist"}) |
53
|
|
|
* @ORM\JoinColumn(name="related_to_id", referencedColumnName="id") |
54
|
|
|
* @JMS\Type("Test\TestBundle\Entity\Car") |
55
|
|
|
*/ |
56
|
|
|
protected $relatedTo; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\OneToMany(targetEntity="Test\TestBundle\Entity\Car", mappedBy="relatedTo", cascade={"persist"}) |
60
|
|
|
* @JMS\Type("ArrayCollection<Test\TestBundle\Entity\Car>") |
61
|
|
|
*/ |
62
|
|
|
protected $relatedCars; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param mixed $id |
66
|
|
|
* |
67
|
|
|
* @return Car |
68
|
|
|
*/ |
69
|
5 |
|
public function setId($id) |
70
|
|
|
{ |
71
|
5 |
|
$this->id = $id; |
72
|
|
|
|
73
|
5 |
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
16 |
|
public function getId() |
80
|
|
|
{ |
81
|
16 |
|
return $this->id; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param mixed $name |
86
|
|
|
* |
87
|
|
|
* @return Car |
88
|
|
|
*/ |
89
|
27 |
|
public function setName($name) |
90
|
|
|
{ |
91
|
27 |
|
$this->name = $name; |
92
|
|
|
|
93
|
27 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return mixed |
98
|
|
|
*/ |
99
|
4 |
|
public function getName() |
100
|
|
|
{ |
101
|
4 |
|
return $this->name; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param mixed $plateNumber |
106
|
|
|
* |
107
|
|
|
* @return Car |
108
|
|
|
*/ |
109
|
27 |
|
public function setPlateNumber($plateNumber) |
110
|
|
|
{ |
111
|
27 |
|
$this->plateNumber = $plateNumber; |
112
|
|
|
|
113
|
27 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
4 |
|
public function getPlateNumber() |
120
|
|
|
{ |
121
|
4 |
|
return $this->plateNumber; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param mixed $password |
126
|
|
|
* |
127
|
|
|
* @return Car |
128
|
|
|
*/ |
129
|
|
|
public function setPassword($password) |
130
|
|
|
{ |
131
|
|
|
$this->password = $password; |
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return mixed |
138
|
|
|
*/ |
139
|
1 |
|
public function getPassword() |
140
|
|
|
{ |
141
|
1 |
|
return $this->password; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Set carOwner |
146
|
|
|
* |
147
|
|
|
* @param CarOwner $carOwner |
148
|
|
|
* @return Car |
149
|
|
|
*/ |
150
|
10 |
|
public function setCarOwner(CarOwner $carOwner = null) |
151
|
|
|
{ |
152
|
10 |
|
$this->carOwner = $carOwner; |
153
|
|
|
|
154
|
10 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Get carOwner |
159
|
|
|
* |
160
|
|
|
* @return CarOwner |
161
|
|
|
*/ |
162
|
8 |
|
public function getCarOwner() |
163
|
|
|
{ |
164
|
8 |
|
return $this->carOwner; |
165
|
|
|
} |
166
|
|
|
/** |
167
|
|
|
* Constructor |
168
|
|
|
*/ |
169
|
27 |
|
public function __construct() |
170
|
|
|
{ |
171
|
27 |
|
$this->relatedCars = new \Doctrine\Common\Collections\ArrayCollection(); |
172
|
27 |
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Add relatedCars |
176
|
|
|
* |
177
|
|
|
* @param \Test\TestBundle\Entity\Car $relatedCars |
178
|
|
|
* @return Car |
179
|
|
|
*/ |
180
|
27 |
|
public function addRelatedCar(\Test\TestBundle\Entity\Car $relatedCars) |
181
|
|
|
{ |
182
|
27 |
|
$this->relatedCars[] = $relatedCars; |
183
|
|
|
|
184
|
27 |
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Remove relatedCars |
189
|
|
|
* |
190
|
|
|
* @param \Test\TestBundle\Entity\Car $relatedCars |
191
|
|
|
*/ |
192
|
|
|
public function removeRelatedCar(\Test\TestBundle\Entity\Car $relatedCars) |
193
|
|
|
{ |
194
|
|
|
$this->relatedCars->removeElement($relatedCars); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Get relatedCars |
199
|
|
|
* |
200
|
|
|
* @return \Doctrine\Common\Collections\Collection |
201
|
|
|
*/ |
202
|
1 |
|
public function getRelatedCars() |
203
|
|
|
{ |
204
|
1 |
|
return $this->relatedCars; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Set relatedTo |
209
|
|
|
* |
210
|
|
|
* @param \Test\TestBundle\Entity\Car $relatedTo |
211
|
|
|
* @return Car |
212
|
|
|
*/ |
213
|
|
|
public function setRelatedTo(\Test\TestBundle\Entity\Car $relatedTo = null) |
214
|
|
|
{ |
215
|
|
|
$this->relatedTo = $relatedTo; |
216
|
|
|
|
217
|
|
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Get relatedTo |
222
|
|
|
* |
223
|
|
|
* @return \Test\TestBundle\Entity\Car |
224
|
|
|
*/ |
225
|
|
|
public function getRelatedTo() |
226
|
|
|
{ |
227
|
|
|
return $this->relatedTo; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
public function mergeRelatedCars(ArrayCollection $list) { |
231
|
|
|
$this->relatedCars = new ArrayCollection(array_merge($this->relatedCars->toArray(), $list->toArray())); |
232
|
|
|
} |
233
|
|
|
} |