|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Bukashk0zzzLiipImagineSerializationBundle |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Denis Golubovskiy <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bukashk0zzz\LiipImagineSerializationBundle\Tests\Fixtures; |
|
13
|
|
|
|
|
14
|
|
|
use Bukashk0zzz\LiipImagineSerializationBundle\Annotation as Bukashk0zzz; |
|
15
|
|
|
use Doctrine\Common\Persistence\Proxy; |
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
17
|
|
|
use JMS\Serializer\Annotation as JMS; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
19
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* UserPictures Entity |
|
23
|
|
|
* |
|
24
|
|
|
* @ORM\Table(name="userPictures") |
|
25
|
|
|
* @ORM\Entity() |
|
26
|
|
|
* @JMS\ExclusionPolicy("all") |
|
27
|
|
|
* @Vich\Uploadable() |
|
28
|
|
|
* @Bukashk0zzz\LiipImagineSerializableClass() |
|
29
|
|
|
*/ |
|
30
|
|
|
class UserPictures implements Proxy |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var string Cover url |
|
34
|
|
|
* @ORM\Column(type="string", length=255) |
|
35
|
|
|
* @JMS\Expose() |
|
36
|
|
|
* @JMS\SerializedName("cover") |
|
37
|
|
|
* @Bukashk0zzz\LiipImagineSerializableField(filter={"big", "small"}) |
|
38
|
|
|
*/ |
|
39
|
|
|
public $coverUrl; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var string Image url |
|
43
|
|
|
* @ORM\Column(type="string", length=255) |
|
44
|
|
|
* @JMS\Expose() |
|
45
|
|
|
* @JMS\SerializedName("image") |
|
46
|
|
|
* @Bukashk0zzz\LiipImagineSerializableField(filter="thumb_filter", virtualField="image_thumb") |
|
47
|
|
|
*/ |
|
48
|
|
|
public $imageUrl; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string Photo name |
|
52
|
|
|
* @ORM\Column(type="string", length=255) |
|
53
|
|
|
* @JMS\Expose() |
|
54
|
|
|
* @JMS\SerializedName("photo") |
|
55
|
|
|
* @Bukashk0zzz\LiipImagineSerializableField(filter="thumb_filter", vichUploaderField="photoFile", virtualField="photoThumb") |
|
56
|
|
|
*/ |
|
57
|
|
|
public $photoName; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var File Photo file |
|
61
|
|
|
* @JMS\Exclude() |
|
62
|
|
|
* @Vich\UploadableField(mapping="user_photo_mapping", fileNameProperty="photoName") |
|
63
|
|
|
*/ |
|
64
|
|
|
public $photoFile; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var User |
|
68
|
|
|
* @ORM\ManyToOne(targetEntity="Bukashk0zzz\LiipImagineSerializationBundle\Tests\Fixtures\User", inversedBy="pictures") |
|
69
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $user; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var int |
|
75
|
|
|
* @ORM\Column(type="integer") |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $userId; |
|
78
|
|
|
|
|
79
|
|
|
/** @var bool */ |
|
80
|
|
|
private $status = false; |
|
81
|
|
|
|
|
82
|
|
|
// @codingStandardsIgnoreStart |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* {@inheritdoc} |
|
86
|
|
|
*/ |
|
87
|
|
|
public function __load() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->setCoverUrl(__DIR__.'/test.png'); |
|
90
|
|
|
$this->setPhotoName('/uploads/photo.jpg'); |
|
91
|
|
|
$this->status = true; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
* |
|
97
|
|
|
* @return bool |
|
98
|
|
|
*/ |
|
99
|
|
|
public function __isInitialized() |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->status; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// @codingStandardsIgnoreEnd |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* To string |
|
108
|
|
|
*/ |
|
109
|
|
|
public function __toString(): string |
|
110
|
|
|
{ |
|
111
|
|
|
return 'New Photo'; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Set userId |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setUserId(int $userId): UserPictures |
|
118
|
|
|
{ |
|
119
|
|
|
$this->userId = $userId; |
|
120
|
|
|
|
|
121
|
|
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Get userId |
|
126
|
|
|
*/ |
|
127
|
|
|
public function getUserId(): int |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->userId; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Set user |
|
134
|
|
|
* |
|
135
|
|
|
* @param User $user |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setUser(?User $user = null): UserPictures |
|
138
|
|
|
{ |
|
139
|
|
|
$this->user = $user; |
|
140
|
|
|
|
|
141
|
|
|
return $this; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Get user |
|
146
|
|
|
*/ |
|
147
|
|
|
public function getUser(): User |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->user; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function getCoverUrl(): string |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->coverUrl; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function setCoverUrl(string $coverUrl): UserPictures |
|
158
|
|
|
{ |
|
159
|
|
|
$this->coverUrl = $coverUrl; |
|
160
|
|
|
|
|
161
|
|
|
return $this; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function getImageUrl(): string |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->imageUrl; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function setImageUrl(string $imageUrl): UserPictures |
|
170
|
|
|
{ |
|
171
|
|
|
$this->imageUrl = $imageUrl; |
|
172
|
|
|
|
|
173
|
|
|
return $this; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @return mixed |
|
178
|
|
|
*/ |
|
179
|
|
|
public function getPhotoName() |
|
180
|
|
|
{ |
|
181
|
|
|
return $this->photoName; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @param mixed $photoName |
|
186
|
|
|
*/ |
|
187
|
|
|
public function setPhotoName($photoName): UserPictures |
|
188
|
|
|
{ |
|
189
|
|
|
$this->photoName = $photoName; |
|
190
|
|
|
|
|
191
|
|
|
return $this; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
public function getPhotoFile(): File |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->photoFile; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public function setPhotoFile(File $photoFile): UserPictures |
|
200
|
|
|
{ |
|
201
|
|
|
$this->photoFile = $photoFile; |
|
202
|
|
|
|
|
203
|
|
|
return $this; |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|