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 DataboxStatus |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @param \stdClass[] $values |
20
|
|
|
* @return DataboxStatus[] |
21
|
|
|
*/ |
22
|
1 |
|
public static function fromList(array $values) |
23
|
|
|
{ |
24
|
1 |
|
$statuses = array(); |
25
|
|
|
|
26
|
1 |
|
foreach ($values as $value) { |
27
|
1 |
|
$statuses[$value->bit] = self::fromValue($value); |
28
|
1 |
|
} |
29
|
|
|
|
30
|
1 |
|
return $statuses; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param \stdClass $value |
35
|
|
|
* @return DataboxStatus |
36
|
|
|
*/ |
37
|
1 |
|
public static function fromValue(\stdClass $value) |
38
|
|
|
{ |
39
|
1 |
|
return new self($value); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var \stdClass |
44
|
|
|
*/ |
45
|
|
|
protected $source; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var ArrayCollection |
49
|
|
|
*/ |
50
|
|
|
protected $labels; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param \stdClass $source |
54
|
|
|
*/ |
55
|
1 |
|
public function __construct(\stdClass $source) |
56
|
|
|
{ |
57
|
1 |
|
$this->source = $source; |
58
|
1 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return \stdClass |
62
|
|
|
*/ |
63
|
|
|
public function getRawData() |
64
|
|
|
{ |
65
|
1 |
|
return $this->source; |
66
|
|
|
} |
67
|
1 |
|
|
68
|
|
|
/** |
69
|
|
|
* Get the status bit |
70
|
|
|
* |
71
|
|
|
* @return integer |
72
|
|
|
*/ |
73
|
|
|
public function getBit() |
74
|
|
|
{ |
75
|
1 |
|
return $this->source->bit; |
76
|
|
|
} |
77
|
1 |
|
|
78
|
|
|
/** |
79
|
|
|
* Get the label status for the ON status state |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function getLabelOn() |
84
|
|
|
{ |
85
|
1 |
|
return $this->source->label_on; |
86
|
|
|
} |
87
|
1 |
|
|
88
|
|
|
/** |
89
|
|
|
* Get the label status for the OFF status state |
90
|
|
|
* |
91
|
|
|
* @return string |
92
|
|
|
*/ |
93
|
|
|
public function getLabelOff() |
94
|
|
|
{ |
95
|
1 |
|
return $this->source->label_off; |
96
|
|
|
} |
97
|
1 |
|
|
98
|
|
|
/** |
99
|
|
|
* Get the image for the ON status state |
100
|
|
|
* |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getImgOn() |
104
|
|
|
{ |
105
|
1 |
|
return $this->source->img_on; |
106
|
|
|
} |
107
|
1 |
|
|
108
|
|
|
/** |
109
|
|
|
* Get the image for the OFF status state |
110
|
|
|
* |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
public function getImgOff() |
114
|
|
|
{ |
115
|
1 |
|
return $this->source->img_off; |
116
|
|
|
} |
117
|
1 |
|
|
118
|
|
|
/** |
119
|
|
|
* Tell whether the status is searchable |
120
|
|
|
* |
121
|
|
|
* @return Boolean |
122
|
|
|
*/ |
123
|
|
|
public function isSearchable() |
124
|
|
|
{ |
125
|
1 |
|
return $this->source->searchable; |
126
|
|
|
} |
127
|
1 |
|
|
128
|
|
|
/** |
129
|
|
|
* Tell whether the status is printable |
130
|
|
|
* |
131
|
|
|
* @return Boolean |
132
|
|
|
*/ |
133
|
1 |
|
public function isPrintable() |
134
|
|
|
{ |
135
|
1 |
|
return $this->source->printable; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return mixed |
140
|
|
|
*/ |
141
|
|
|
public function getLabels() |
142
|
|
|
{ |
143
|
|
|
return $this->labels ?: $this->labels = new ArrayCollection((array) $this->source->labels); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|