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 MeCollection |
17
|
|
|
{ |
18
|
|
|
public static function fromList($values) |
19
|
|
|
{ |
20
|
|
|
$collections = array(); |
21
|
|
|
|
22
|
|
|
foreach ($values as $value) { |
23
|
|
|
$collections[$value->base_id] = self::fromValue($value); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
return $collections; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public static function fromValue(\stdClass $value) |
30
|
|
|
{ |
31
|
|
|
return new self($value); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var \stdClass |
36
|
|
|
*/ |
37
|
|
|
protected $source; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var ArrayCollection |
41
|
|
|
*/ |
42
|
|
|
protected $labels; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param \stdClass $source |
46
|
|
|
*/ |
47
|
|
|
public function __construct(\stdClass $source) |
48
|
|
|
{ |
49
|
|
|
$this->source = $source; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \stdClass |
54
|
|
|
*/ |
55
|
|
|
public function getRawData() |
56
|
|
|
{ |
57
|
|
|
return $this->source; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* The logo base64 |
62
|
|
|
* |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getLogo() |
66
|
|
|
{ |
67
|
|
|
return $this->source->logo; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* The collection base id |
72
|
|
|
* |
73
|
|
|
* @return integer |
74
|
|
|
*/ |
75
|
|
|
public function getBaseId() |
76
|
|
|
{ |
77
|
|
|
return $this->source->base_id; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The databox id |
82
|
|
|
* |
83
|
|
|
* @return integer |
84
|
|
|
*/ |
85
|
|
|
public function getDataboxId() |
86
|
|
|
{ |
87
|
|
|
return $this->source->databox_id; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* The collection id |
92
|
|
|
* |
93
|
|
|
* @return integer |
94
|
|
|
*/ |
95
|
|
|
public function getCollectionId() |
96
|
|
|
{ |
97
|
|
|
return $this->source->collection_id; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* The collection name |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getName() |
106
|
|
|
{ |
107
|
|
|
return $this->source->name; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* The collection rights |
112
|
|
|
* |
113
|
|
|
* @return array |
114
|
|
|
*/ |
115
|
|
|
public function getRights() |
116
|
|
|
{ |
117
|
|
|
return $this->source->rights; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* The collection rights |
122
|
|
|
* |
123
|
|
|
* @return array |
124
|
|
|
*/ |
125
|
|
|
public function getStatuses() |
126
|
|
|
{ |
127
|
|
|
return $this->source->statuses; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return ArrayCollection|string[] |
132
|
|
|
*/ |
133
|
|
|
public function getLabels() |
134
|
|
|
{ |
135
|
|
|
return $this->labels ?: $this->labels = new ArrayCollection((array) $this->source->labels); |
136
|
|
|
} |
137
|
|
|
} |