1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,85 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+declare(strict_types=1); |
|
4 |
+ |
|
5 |
+/* |
|
6 |
+ * This file is part of alox bundle for Contao. |
|
7 |
+ * |
|
8 |
+ * (c) Benjamin Roth |
|
9 |
+ * |
|
10 |
+ * @license commercial |
|
11 |
+ */ |
|
12 |
+ |
|
13 |
+namespace vossmedien\AloxBundle\Model; |
|
14 |
+ |
|
15 |
+class KatalogModel implements \ArrayAccess, \Countable, \IteratorAggregate |
|
16 |
+{ |
|
17 |
+ /** |
|
18 |
+ * @var int |
|
19 |
+ */ |
|
20 |
+ private int $TotalItems; |
|
21 |
+ |
|
22 |
+ /** |
|
23 |
+ * @var array |
|
24 |
+ */ |
|
25 |
+ private array $Items; |
|
26 |
+ |
|
27 |
+ public function __get($name) |
|
28 |
+ { |
|
29 |
+ if (isset($this->{$name}) && method_exists($this,'get'.$name)) |
|
30 |
+ { |
|
31 |
+ return $this->{'get'.$name}(); |
|
32 |
+ } |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ |
|
36 |
+ public function getItems(): array |
|
37 |
+ { |
|
38 |
+ return $this->Items; |
|
39 |
+ } |
|
40 |
+ |
|
41 |
+ public function getTotalItems(): int |
|
42 |
+ { |
|
43 |
+ return $this->TotalItems; |
|
44 |
+ } |
|
45 |
+ |
|
46 |
+ public function setItems(array $items): void |
|
47 |
+ { |
|
48 |
+ $this->Items = $items; |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ public function setTotalItems(int $total): void |
|
52 |
+ { |
|
53 |
+ $this->TotalItems = $total; |
|
54 |
+ } |
|
55 |
+ |
|
56 |
+ public function getIterator() |
|
57 |
+ { |
|
58 |
+ return new \ArrayIterator($this->Items); |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ public function offsetExists($offset) |
|
62 |
+ { |
|
63 |
+ return isset($this->Items[$offset]); |
|
64 |
+ } |
|
65 |
+ |
|
66 |
+ public function offsetGet($offset) |
|
67 |
+ { |
|
68 |
+ return $this->Items[$offset]; |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ public function offsetSet($offset, $value) |
|
72 |
+ { |
|
73 |
+ throw new \RuntimeException('This collection is immutable'); |
|
74 |
+ } |
|
75 |
+ |
|
76 |
+ public function offsetUnset($offset) |
|
77 |
+ { |
|
78 |
+ throw new \RuntimeException('This collection is immutable'); |
|
79 |
+ } |
|
80 |
+ |
|
81 |
+ public function count() |
|
82 |
+ { |
|
83 |
+ return \count($this->Items); |
|
84 |
+ } |
|
85 |
+} |