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