1 | <?php namespace Rocket\Entities; |
||
8 | class FieldCollection extends \Illuminate\Support\Collection |
||
9 | { |
||
10 | /** |
||
11 | * @var int The max items this collection can hold |
||
12 | */ |
||
13 | protected $maxItems = 1; |
||
14 | |||
15 | /** |
||
16 | * @var array The Collection configuration |
||
17 | */ |
||
18 | protected $configuration = []; |
||
19 | |||
20 | /** |
||
21 | * @var string The type of this collection |
||
22 | */ |
||
23 | protected $type; |
||
24 | |||
25 | /** |
||
26 | * @var array An array of fields that were deleted |
||
27 | */ |
||
28 | protected $deleted = []; |
||
29 | |||
30 | /** |
||
31 | * Initialize a collection with the configuration |
||
32 | * |
||
33 | * @param array $configuration |
||
34 | * @throws InvalidFieldTypeException |
||
35 | * @return static |
||
36 | */ |
||
37 | 102 | public static function initField($configuration = []) |
|
53 | |||
54 | /** |
||
55 | * Validate input of OffsetSet |
||
56 | * |
||
57 | * @param $key |
||
58 | * @param $value |
||
59 | * @throws ItemCountException |
||
60 | * @throws NullValueException |
||
61 | */ |
||
62 | 81 | protected function validateSet($key, $value) { |
|
71 | |||
72 | /** |
||
73 | * Get a field from a value |
||
74 | * |
||
75 | * @param Field|mixed $value |
||
76 | * @return Field |
||
77 | */ |
||
78 | 78 | protected function getFieldInstance($value) { |
|
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | 81 | public function offsetSet($key, $value) |
|
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | 6 | public function offsetGet($key) |
|
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | 24 | public function offsetUnset($key) |
|
133 | |||
134 | /** |
||
135 | * Get all deleted fields |
||
136 | * |
||
137 | * @return Collection |
||
138 | */ |
||
139 | 27 | public function deleted() |
|
143 | |||
144 | /** |
||
145 | * Mark the content as current and saved |
||
146 | */ |
||
147 | 15 | public function syncOriginal() |
|
151 | |||
152 | /** |
||
153 | * Remove all items in this collection |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | 15 | public function clear() |
|
165 | |||
166 | /** |
||
167 | * Get the number of items possible in this collection. |
||
168 | * |
||
169 | * @return int |
||
170 | */ |
||
171 | 84 | public function getMaxItems() |
|
175 | |||
176 | /** |
||
177 | * As we use a field collection even if we have only one value, we use it that way. |
||
178 | * |
||
179 | * @return array|mixed|null |
||
180 | */ |
||
181 | 43 | public function toArray() |
|
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | 6 | public function __toString() |
|
205 | } |
||
206 |