|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Phraseanet SDK. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Alchemy <[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 PhraseanetSDK\Entity; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
15
|
|
|
|
|
16
|
|
|
class Quarantine |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
1 |
|
public static function fromList(array $values) |
|
20
|
|
|
{ |
|
21
|
1 |
|
$quarantines = array(); |
|
22
|
|
|
|
|
23
|
1 |
|
foreach ($values as $value) { |
|
24
|
1 |
|
$quarantines[$value->id] = self::fromValue($value); |
|
25
|
1 |
|
} |
|
26
|
|
|
|
|
27
|
1 |
|
return $quarantines; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
2 |
|
public static function fromValue(\stdClass $value) |
|
31
|
|
|
{ |
|
32
|
2 |
|
return new self($value); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var \stdClass |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $source; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var QuarantineSession |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $session; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string[]|ArrayCollection |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $checks; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var \DateTime |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $createdOn; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var \DateTime |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $updatedOn; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param \stdClass $source |
|
62
|
|
|
*/ |
|
63
|
2 |
|
public function __construct(\stdClass $source) |
|
64
|
|
|
{ |
|
65
|
2 |
|
$this->source = $source; |
|
66
|
2 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return \stdClass |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getRawData() |
|
72
|
|
|
{ |
|
73
|
2 |
|
return $this->source; |
|
74
|
|
|
} |
|
75
|
2 |
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Get Quarantine item id |
|
78
|
|
|
* |
|
79
|
|
|
* @return integer |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getId() |
|
82
|
|
|
{ |
|
83
|
2 |
|
return $this->source->id; |
|
84
|
|
|
} |
|
85
|
2 |
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get The related quarantine session |
|
88
|
|
|
* |
|
89
|
|
|
* @return QuarantineSession |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getSession() |
|
92
|
|
|
{ |
|
93
|
2 |
|
return $this->session ?: $this->session = QuarantineSession::fromValue($this->source->quarantine_session); |
|
94
|
|
|
} |
|
95
|
2 |
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Get the related base id |
|
98
|
|
|
* |
|
99
|
|
|
* @return integer |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getBaseId() |
|
102
|
|
|
{ |
|
103
|
2 |
|
return $this->source->base_id; |
|
104
|
|
|
} |
|
105
|
2 |
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get the item original name |
|
108
|
|
|
* |
|
109
|
|
|
* @return string |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getOriginalName() |
|
112
|
|
|
{ |
|
113
|
2 |
|
return $this->source->original_name; |
|
114
|
|
|
} |
|
115
|
2 |
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Get the item SHA 256 HASH |
|
118
|
|
|
* |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getSha256() |
|
122
|
|
|
{ |
|
123
|
2 |
|
return $this->source->sha256; |
|
124
|
|
|
} |
|
125
|
2 |
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get the item UUID |
|
128
|
|
|
* |
|
129
|
|
|
* @return string |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getUuid() |
|
132
|
|
|
{ |
|
133
|
2 |
|
return $this->source->uuid; |
|
134
|
|
|
} |
|
135
|
2 |
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Tell whether the item has been forced to the quarantine |
|
138
|
|
|
* |
|
139
|
|
|
* @return Boolean |
|
140
|
|
|
*/ |
|
141
|
|
|
public function isForced() |
|
142
|
|
|
{ |
|
143
|
2 |
|
return $this->source->forced; |
|
144
|
|
|
} |
|
145
|
2 |
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Get the check messages as a collection of string |
|
148
|
|
|
* |
|
149
|
|
|
* @return string[] |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getChecks() |
|
152
|
|
|
{ |
|
153
|
2 |
|
return $this->checks ?: $this->checks = new ArrayCollection($this->source->checks); |
|
154
|
|
|
} |
|
155
|
2 |
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Creation date |
|
158
|
|
|
* |
|
159
|
|
|
* @return \DateTime |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getCreatedOn() |
|
162
|
|
|
{ |
|
163
|
2 |
|
return $this->createdOn ?: new \DateTime($this->source->created_on); |
|
164
|
|
|
} |
|
165
|
2 |
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Last updated date |
|
168
|
|
|
* |
|
169
|
|
|
* @return \DateTime |
|
170
|
|
|
*/ |
|
171
|
|
|
public function getUpdatedOn() |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->updatedOn ?: new \DateTime($this->source->updated_on); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|