1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
4
|
|
|
|
5
|
|
|
use JMS\Serializer\Annotation\Type; |
6
|
|
|
use JMS\Serializer\Annotation\HandlerCallback; |
7
|
|
|
use JMS\Serializer\JsonDeserializationVisitor; |
8
|
|
|
use JMS\Serializer\DeserializationContext; |
9
|
|
|
use MovingImage\Meta\Interfaces\AttachmentInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Attachment. |
13
|
|
|
*/ |
14
|
|
|
class Attachment implements AttachmentInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @Type("string") |
18
|
|
|
*/ |
19
|
|
|
private $id; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @Type("string") |
23
|
|
|
*/ |
24
|
|
|
private $fileName; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @Type("string") |
28
|
|
|
*/ |
29
|
|
|
private $downloadUrl; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @Type("int") |
33
|
|
|
*/ |
34
|
|
|
private $fileSize; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @Type("string") |
38
|
|
|
*/ |
39
|
|
|
private $type; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getId() |
45
|
|
|
{ |
46
|
|
|
return $this->id; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param $id |
51
|
|
|
* |
52
|
|
|
* @return Attachment |
53
|
|
|
*/ |
54
|
|
|
public function setId($id) |
55
|
|
|
{ |
56
|
|
|
$this->id = $id; |
57
|
|
|
|
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getFileName() |
65
|
|
|
{ |
66
|
|
|
return $this->fileName; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param $fileName |
71
|
|
|
* |
72
|
|
|
* @return Attachment |
73
|
|
|
*/ |
74
|
|
|
public function setFileName($fileName) |
75
|
|
|
{ |
76
|
|
|
$this->fileName = $fileName; |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getDownloadUrl() |
85
|
|
|
{ |
86
|
|
|
return $this->downloadUrl; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param $downloadUrl |
91
|
|
|
* |
92
|
|
|
* @return Attachment |
93
|
|
|
*/ |
94
|
|
|
public function setDownloadUrl($downloadUrl) |
95
|
|
|
{ |
96
|
|
|
$this->downloadUrl = $downloadUrl; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return int |
103
|
|
|
*/ |
104
|
|
|
public function getFileSize() |
105
|
|
|
{ |
106
|
|
|
return $this->fileSize; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param $fileSize |
111
|
|
|
* |
112
|
|
|
* @return Attachment |
113
|
|
|
*/ |
114
|
|
|
public function setFileSize($fileSize) |
115
|
|
|
{ |
116
|
|
|
$this->fileSize = $fileSize; |
117
|
|
|
|
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function getType() |
125
|
|
|
{ |
126
|
|
|
return $this->type; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param $type |
131
|
|
|
* |
132
|
|
|
* @return Attachment |
133
|
|
|
*/ |
134
|
|
|
public function setType($type) |
135
|
|
|
{ |
136
|
|
|
$this->type = $type; |
137
|
|
|
|
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @HandlerCallback("json", direction = "deserialization") |
143
|
|
|
*/ |
144
|
|
|
public function deserializeFromJson(JsonDeserializationVisitor $visitor, array $data, DeserializationContext $context) |
|
|
|
|
145
|
|
|
{ |
146
|
|
|
if (isset($data['data']['id'])) { |
147
|
|
|
$this->id = $data['data']['id']; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
if (isset($data['data']['fileName'])) { |
151
|
|
|
$this->fileName = $data['data']['fileName']; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
if (isset($data['data']['downloadUrl'])) { |
155
|
|
|
$this->downloadUrl = $data['data']['downloadUrl']; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if (isset($data['data']['fileSize'])) { |
159
|
|
|
$this->fileSize = $data['data']['fileSize']; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
if (isset($data['type']['name'])) { |
163
|
|
|
$this->type = $data['type']['name']; |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.