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 | * {@inheritdoc} |
||
56 | */ |
||
57 | 81 | public function offsetSet($key, $value) |
|
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | 6 | public function offsetGet($key) |
|
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | 24 | public function offsetUnset($key) |
|
108 | |||
109 | /** |
||
110 | * Get all deleted fields |
||
111 | * |
||
112 | * @return Collection |
||
113 | */ |
||
114 | 27 | public function deleted() |
|
118 | |||
119 | /** |
||
120 | * Mark the content as current and saved |
||
121 | */ |
||
122 | 15 | public function syncOriginal() |
|
126 | |||
127 | /** |
||
128 | * Remove all items in this collection |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | 15 | public function clear() |
|
140 | |||
141 | /** |
||
142 | * Get the number of items possible in this collection. |
||
143 | * |
||
144 | * @return int |
||
145 | */ |
||
146 | 84 | public function getMaxItems() |
|
150 | |||
151 | /** |
||
152 | * As we use a field collection even if we have only one value, we use it that way. |
||
153 | * |
||
154 | * @return array|mixed|null |
||
155 | */ |
||
156 | 43 | public function toArray() |
|
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | 6 | public function __toString() |
|
180 | } |
||
181 |