|
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
|
|
|
class BasketValidationChoice |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
1 |
|
public static function fromList(array $values) |
|
18
|
|
|
{ |
|
19
|
1 |
|
$choices = array(); |
|
20
|
|
|
|
|
21
|
1 |
|
foreach ($values as $value) { |
|
22
|
1 |
|
$choices[] = self::fromValue($value); |
|
23
|
1 |
|
} |
|
24
|
|
|
|
|
25
|
1 |
|
return $choices; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
1 |
|
public static function fromValue(\stdClass $value) |
|
29
|
|
|
{ |
|
30
|
1 |
|
return new self($value); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var \stdClass |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $source; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var \DateTime|null |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $updatedOn; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var BasketValidationParticipant |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $participant; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param \stdClass $source |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function __construct(\stdClass $source) |
|
52
|
|
|
{ |
|
53
|
1 |
|
$this->source = $source; |
|
54
|
1 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return \stdClass |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getRawData() |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->source; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Get the validation user |
|
66
|
|
|
* |
|
67
|
|
|
* @return BasketValidationParticipant |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function getParticipant() |
|
70
|
|
|
{ |
|
71
|
1 |
|
return $this->participant ?: $this->participant = BasketValidationParticipant::fromValue( |
|
72
|
1 |
|
$this->source->validation_user |
|
73
|
1 |
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Get last update date |
|
78
|
|
|
* |
|
79
|
|
|
* @return \DateTime |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public function getUpdatedOn() |
|
82
|
|
|
{ |
|
83
|
1 |
|
return $this->updatedOn ?: $this->updatedOn = new \DateTime($this->source->updated_on); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get the annotation about the validation of the current authenticated user |
|
88
|
|
|
* |
|
89
|
|
|
* @return int |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function getNote() |
|
92
|
|
|
{ |
|
93
|
1 |
|
return (int) $this->source->note; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Get the agreement of the current authenticated user |
|
98
|
|
|
* |
|
99
|
|
|
* - null : no response yet |
|
100
|
|
|
* - true : accepted |
|
101
|
|
|
* - false: rejected |
|
102
|
|
|
* |
|
103
|
|
|
* @return null|boolean |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function getAgreement() |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->source->agreement; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|