1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\AssetBundle\Entity; |
||
13 | |||
14 | use Doctrine\ORM\Mapping as ORM; |
||
15 | use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; |
||
16 | use Mautic\EmailBundle\Entity\Email; |
||
17 | |||
18 | /** |
||
19 | * Class Download. |
||
20 | */ |
||
21 | class Download |
||
22 | { |
||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | private $id; |
||
27 | |||
28 | /** |
||
29 | * @var \DateTime |
||
30 | */ |
||
31 | private $dateDownload; |
||
32 | |||
33 | /** |
||
34 | * @var Asset |
||
35 | */ |
||
36 | private $asset; |
||
37 | |||
38 | /** |
||
39 | * @var \Mautic\CoreBundle\Entity\IpAddress |
||
40 | */ |
||
41 | private $ipAddress; |
||
42 | |||
43 | /** |
||
44 | * @var \Mautic\LeadBundle\Entity\Lead |
||
45 | */ |
||
46 | private $lead; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $code; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | private $referer; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | private $trackingId; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | */ |
||
66 | private $source; |
||
67 | |||
68 | /** |
||
69 | * @var string |
||
70 | */ |
||
71 | private $sourceId; |
||
72 | |||
73 | /** |
||
74 | * @var \Mautic\EmailBundle\Entity\Email |
||
75 | */ |
||
76 | private $email; |
||
77 | |||
78 | public static function loadMetadata(ORM\ClassMetadata $metadata) |
||
79 | { |
||
80 | $builder = new ClassMetadataBuilder($metadata); |
||
81 | |||
82 | $builder->setTable('asset_downloads') |
||
83 | ->setCustomRepositoryClass('Mautic\AssetBundle\Entity\DownloadRepository') |
||
84 | ->addIndex(['tracking_id'], 'download_tracking_search') |
||
85 | ->addIndex(['source', 'source_id'], 'download_source_search') |
||
86 | ->addIndex(['date_download'], 'asset_date_download'); |
||
87 | |||
88 | $builder->addBigIntIdField(); |
||
89 | |||
90 | $builder->createField('dateDownload', 'datetime') |
||
91 | ->columnName('date_download') |
||
92 | ->build(); |
||
93 | |||
94 | $builder->createManyToOne('asset', 'Asset') |
||
95 | ->addJoinColumn('asset_id', 'id', true, false, 'CASCADE') |
||
96 | ->build(); |
||
97 | |||
98 | $builder->addIpAddress(); |
||
99 | |||
100 | $builder->addLead(true, 'SET NULL'); |
||
101 | |||
102 | $builder->addField('code', 'integer'); |
||
103 | |||
104 | $builder->createField('referer', 'text') |
||
105 | ->nullable() |
||
106 | ->build(); |
||
107 | |||
108 | $builder->createField('trackingId', 'string') |
||
109 | ->columnName('tracking_id') |
||
110 | ->build(); |
||
111 | |||
112 | $builder->createField('source', 'string') |
||
113 | ->nullable() |
||
114 | ->build(); |
||
115 | |||
116 | $builder->createField('sourceId', 'integer') |
||
117 | ->columnName('source_id') |
||
118 | ->nullable() |
||
119 | ->build(); |
||
120 | |||
121 | $builder->createManyToOne('email', 'Mautic\EmailBundle\Entity\Email') |
||
122 | ->addJoinColumn('email_id', 'id', true, false, 'SET NULL') |
||
123 | ->build(); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Get id. |
||
128 | * |
||
129 | * @return int |
||
130 | */ |
||
131 | public function getId() |
||
132 | { |
||
133 | return $this->id; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Set dateDownload. |
||
138 | * |
||
139 | * @param \DateTime $dateDownload |
||
140 | * |
||
141 | * @return Download |
||
142 | */ |
||
143 | public function setDateDownload($dateDownload) |
||
144 | { |
||
145 | $this->dateDownload = $dateDownload; |
||
146 | |||
147 | return $this; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Get dateDownload. |
||
152 | * |
||
153 | * @return \DateTime |
||
154 | */ |
||
155 | public function getDateDownload() |
||
156 | { |
||
157 | return $this->dateDownload; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Set code. |
||
162 | * |
||
163 | * @param int $code |
||
164 | * |
||
165 | * @return Download |
||
166 | */ |
||
167 | public function setCode($code) |
||
168 | { |
||
169 | $this->code = $code; |
||
170 | |||
171 | return $this; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Get code. |
||
176 | * |
||
177 | * @return int |
||
178 | */ |
||
179 | public function getCode() |
||
180 | { |
||
181 | return $this->code; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Set referer. |
||
186 | * |
||
187 | * @param string $referer |
||
188 | * |
||
189 | * @return Download |
||
190 | */ |
||
191 | public function setReferer($referer) |
||
192 | { |
||
193 | $this->referer = $referer; |
||
194 | |||
195 | return $this; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * Get referer. |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | public function getReferer() |
||
204 | { |
||
205 | return $this->referer; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * Set asset. |
||
210 | * |
||
211 | * @param Asset $asset |
||
212 | * |
||
213 | * @return Download |
||
214 | */ |
||
215 | public function setAsset(Asset $asset = null) |
||
216 | { |
||
217 | $this->asset = $asset; |
||
218 | |||
219 | return $this; |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * Get asset. |
||
224 | * |
||
225 | * @return Asset |
||
226 | */ |
||
227 | public function getAsset() |
||
228 | { |
||
229 | return $this->asset; |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * Set ipAddress. |
||
234 | * |
||
235 | * @return Download |
||
236 | */ |
||
237 | public function setIpAddress(\Mautic\CoreBundle\Entity\IpAddress $ipAddress) |
||
238 | { |
||
239 | $this->ipAddress = $ipAddress; |
||
240 | |||
241 | return $this; |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Get ipAddress. |
||
246 | * |
||
247 | * @return \Mautic\CoreBundle\Entity\IpAddress |
||
248 | */ |
||
249 | public function getIpAddress() |
||
250 | { |
||
251 | return $this->ipAddress; |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * Set trackingId. |
||
256 | * |
||
257 | * @param int $trackingId |
||
258 | * |
||
259 | * @return Download |
||
260 | */ |
||
261 | public function setTrackingId($trackingId) |
||
262 | { |
||
263 | $this->trackingId = $trackingId; |
||
264 | |||
265 | return $this; |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * Get trackingId. |
||
270 | * |
||
271 | * @return int |
||
272 | */ |
||
273 | public function getTrackingId() |
||
274 | { |
||
275 | return $this->trackingId; |
||
0 ignored issues
–
show
|
|||
276 | } |
||
277 | |||
278 | /** |
||
279 | * @return mixed |
||
280 | */ |
||
281 | public function getLead() |
||
282 | { |
||
283 | return $this->lead; |
||
284 | } |
||
285 | |||
286 | /** |
||
287 | * @param mixed $lead |
||
288 | */ |
||
289 | public function setLead($lead) |
||
290 | { |
||
291 | $this->lead = $lead; |
||
292 | } |
||
293 | |||
294 | /** |
||
295 | * @return mixed |
||
296 | */ |
||
297 | public function getSource() |
||
298 | { |
||
299 | return $this->source; |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * @param mixed $source |
||
304 | */ |
||
305 | public function setSource($source) |
||
306 | { |
||
307 | $this->source = $source; |
||
308 | } |
||
309 | |||
310 | /** |
||
311 | * @return int |
||
312 | */ |
||
313 | public function getSourceId() |
||
314 | { |
||
315 | return $this->sourceId; |
||
316 | } |
||
317 | |||
318 | /** |
||
319 | * @param mixed $sourceId |
||
320 | */ |
||
321 | public function setSourceId($sourceId) |
||
322 | { |
||
323 | $this->sourceId = (int) $sourceId; |
||
324 | } |
||
325 | |||
326 | /** |
||
327 | * @return mixed |
||
328 | */ |
||
329 | public function getEmail() |
||
330 | { |
||
331 | return $this->email; |
||
332 | } |
||
333 | |||
334 | /** |
||
335 | * @param mixed $email |
||
336 | */ |
||
337 | public function setEmail(Email $email) |
||
338 | { |
||
339 | $this->email = $email; |
||
340 | } |
||
341 | } |
||
342 |