|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace One\Model; |
|
4
|
|
|
|
|
5
|
|
|
use One\Collection; |
|
6
|
|
|
|
|
7
|
|
|
class Livereport extends Model |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* identifier |
|
11
|
|
|
* |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $identifier = null; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* constuctor |
|
18
|
|
|
* |
|
19
|
|
|
* @param string $uniqueId |
|
20
|
|
|
* @param string $title |
|
21
|
|
|
* @param string $shortDesc |
|
22
|
|
|
* @param \DateTimeInterface|string $publishDat |
|
23
|
|
|
* @param \DateTimeInterface|string $endDate |
|
24
|
|
|
* @param string $tag |
|
25
|
|
|
* @param bool $isHeadline |
|
26
|
|
|
* @param bool $published |
|
27
|
|
|
* @param string $livereportChild |
|
28
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
public function __construct( |
|
32
|
|
|
string $uniqueId, |
|
33
|
|
|
string $title, |
|
34
|
|
|
string $shortDesc, |
|
35
|
|
|
$publishDate = null, |
|
36
|
|
|
$endDate = null, |
|
37
|
|
|
string $tag = null, |
|
38
|
|
|
$isHeadline = false, |
|
39
|
|
|
$published = false, |
|
40
|
|
|
string $livereportChild = null, |
|
41
|
|
|
string $imageThumbnail, |
|
42
|
|
|
string $reporterName, |
|
43
|
|
|
string $reporterAvatar, |
|
44
|
|
|
string $editorName, |
|
45
|
|
|
string $editorAvatar, |
|
46
|
|
|
$identifier = null |
|
47
|
|
|
|
|
48
|
|
|
) { |
|
49
|
|
|
$properties = [ |
|
50
|
|
|
'unique_id' => $uniqueId, |
|
51
|
|
|
'title' => $this->filterStringInstance($title), |
|
52
|
|
|
'short_desc' => $this->filterStringInstance($shortDesc), |
|
53
|
|
|
'publish_date' => $this->filterDateInstance($publishDate), |
|
54
|
|
|
'end_date' => $this->filterDateInstance($endDate), |
|
55
|
|
|
'tag' => $this->filterStringInstance($tag), |
|
56
|
|
|
'is_headline' => $isHeadline ? 1 : 0, |
|
57
|
|
|
'published' => $published ? 1 : 0, |
|
58
|
|
|
'livereport_child' => $this->filterStringInstance($livereportChild), |
|
59
|
|
|
'image_thumbnail' => $this->filterStringInstance($imageThumbnail), |
|
60
|
|
|
'reporter_name' => $this->filterStringInstance($reporterName), |
|
61
|
|
|
'reporter_avatar' => $this->filterStringInstance($reporterAvatar), |
|
62
|
|
|
'editor_name' => $this->filterStringInstance($editorName), |
|
63
|
|
|
'editor_avatar' => $this->filterStringInstance($editorAvatar), |
|
64
|
|
|
]; |
|
65
|
|
|
|
|
66
|
|
|
$this->collection = new Collection($properties); |
|
67
|
|
|
|
|
68
|
|
|
if ($identifier) { |
|
69
|
|
|
$this->setId((string) $identifier); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* setIdentifier from rest api response |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setId(string $identifier): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->identifier = $identifier; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* getIdentifier set before |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getId(): string |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->identifier; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
|