1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the FreshVichUploaderSerializationBundle |
4
|
|
|
* |
5
|
|
|
* (c) Artem Henvald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Fresh\VichUploaderSerializationBundle\Tests\Fixtures; |
12
|
|
|
|
13
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
15
|
|
|
use Fresh\VichUploaderSerializationBundle\Annotation as Fresh; |
16
|
|
|
use JMS\Serializer\Annotation as JMS; |
17
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
18
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* UserA Entity. |
22
|
|
|
* |
23
|
|
|
* @ORM\Table(name="users") |
24
|
|
|
* @ORM\Entity() |
25
|
|
|
* |
26
|
|
|
* @JMS\ExclusionPolicy("all") |
27
|
|
|
* |
28
|
|
|
* @Vich\Uploadable |
29
|
|
|
* |
30
|
|
|
* @Fresh\VichSerializableClass |
31
|
|
|
*/ |
32
|
|
|
class UserA |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(type="string", length=255) |
38
|
|
|
* |
39
|
|
|
* @JMS\Expose |
40
|
|
|
* @JMS\SerializedName("photo") |
41
|
|
|
* |
42
|
|
|
* @Fresh\VichSerializableField("photoFile") |
43
|
|
|
*/ |
44
|
|
|
private $photoName; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var File |
48
|
|
|
* |
49
|
|
|
* @JMS\Exclude |
50
|
|
|
* |
51
|
|
|
* @Vich\UploadableField(mapping="user_photo_mapping", fileNameProperty="photoName") |
52
|
|
|
*/ |
53
|
|
|
private $photoFile; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(type="string", length=255) |
59
|
|
|
* |
60
|
|
|
* @JMS\Expose |
61
|
|
|
* @JMS\SerializedName("cover") |
62
|
|
|
* |
63
|
|
|
* @Fresh\VichSerializableField("coverFile") |
64
|
|
|
*/ |
65
|
|
|
private $coverName; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var File |
69
|
|
|
* |
70
|
|
|
* @JMS\Exclude |
71
|
|
|
* |
72
|
|
|
* @Vich\UploadableField(mapping="user_cover_mapping", fileNameProperty="coverName") |
73
|
|
|
*/ |
74
|
|
|
private $coverFile; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var UserPicture[]|ArrayCollection |
78
|
|
|
* |
79
|
|
|
* @ORM\OneToMany(targetEntity="Fresh\VichUploaderSerializationBundle\Tests\Fixtures\UserPictures", mappedBy="user") |
80
|
|
|
*/ |
81
|
|
|
protected $userPictures; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function __toString() |
87
|
|
|
{ |
88
|
|
|
return 'New User'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getPhotoName() |
95
|
|
|
{ |
96
|
|
|
return $this->photoName; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $photoName |
101
|
|
|
* |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
|
|
public function setPhotoName($photoName) |
105
|
|
|
{ |
106
|
|
|
$this->photoName = $photoName; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return File |
113
|
|
|
*/ |
114
|
|
|
public function getPhotoFile() |
115
|
|
|
{ |
116
|
|
|
return $this->photoFile; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param File $photoFile |
121
|
|
|
* |
122
|
|
|
* @return $this |
123
|
|
|
*/ |
124
|
|
|
public function setPhotoFile(File $photoFile) |
125
|
|
|
{ |
126
|
|
|
$this->photoFile = $photoFile; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
public function getCoverName() |
135
|
|
|
{ |
136
|
|
|
return $this->coverName; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string $coverName |
141
|
|
|
* |
142
|
|
|
* @return $this |
143
|
|
|
*/ |
144
|
|
|
public function setCoverName($coverName) |
145
|
|
|
{ |
146
|
|
|
$this->coverName = $coverName; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return File |
153
|
|
|
*/ |
154
|
|
|
public function getCoverFile() |
155
|
|
|
{ |
156
|
|
|
return $this->coverFile; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param File $coverFile |
161
|
|
|
* |
162
|
|
|
* @return $this |
163
|
|
|
*/ |
164
|
|
|
public function setCoverFile(File $coverFile) |
165
|
|
|
{ |
166
|
|
|
$this->coverFile = $coverFile; |
167
|
|
|
|
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param UserPicture $userPicture |
173
|
|
|
* |
174
|
|
|
* @return $this |
175
|
|
|
*/ |
176
|
|
|
public function addUserPictures(UserPicture $userPicture) |
177
|
|
|
{ |
178
|
|
|
$this->userPictures[] = $userPicture; |
179
|
|
|
|
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param UserPicture $userPictures |
185
|
|
|
*/ |
186
|
|
|
public function removeUserPictures(UserPicture $userPictures) |
187
|
|
|
{ |
188
|
|
|
$this->userPictures->removeElement($userPictures); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return UserPicture[]|ArrayCollection |
193
|
|
|
*/ |
194
|
|
|
public function getUserPictures() |
195
|
|
|
{ |
196
|
|
|
return $this->userPictures; |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|