1 | <?php |
||
24 | abstract class AbstractCrud implements CrudInterface |
||
25 | { |
||
26 | use Instance; |
||
27 | |||
28 | /** |
||
29 | * @var array Fields for action |
||
30 | * @todo should be different for Create, Read and Update |
||
31 | */ |
||
32 | protected $fields = []; |
||
33 | |||
34 | /** |
||
35 | * Return primary key signature |
||
36 | * |
||
37 | * @return array |
||
38 | */ |
||
39 | abstract public function getPrimaryKey() : array; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | * |
||
44 | * @throws NotImplementedException |
||
45 | */ |
||
46 | 1 | public function readOne($primary) |
|
47 | { |
||
48 | 1 | throw new NotImplementedException; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | * |
||
54 | * @throws NotImplementedException |
||
55 | */ |
||
56 | 1 | public function readSet($offset = 0, $limit = self::DEFAULT_LIMIT, $params = []) |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | * |
||
64 | * @throws NotImplementedException |
||
65 | */ |
||
66 | 1 | public function createOne($data) |
|
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | * |
||
74 | * @throws NotImplementedException |
||
75 | */ |
||
76 | 1 | public function createSet($data) |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | * |
||
84 | * @throws NotImplementedException |
||
85 | */ |
||
86 | 1 | public function updateOne($primary, $data) |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | * |
||
94 | * @throws NotImplementedException |
||
95 | */ |
||
96 | 1 | public function updateSet($data) |
|
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | * |
||
104 | * @throws NotImplementedException |
||
105 | */ |
||
106 | 1 | public function deleteOne($primary) |
|
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | * |
||
114 | * @throws NotImplementedException |
||
115 | */ |
||
116 | 1 | public function deleteSet($data) |
|
120 | |||
121 | /** |
||
122 | * @return array |
||
123 | */ |
||
124 | 6 | public function getFields() : array |
|
128 | |||
129 | /** |
||
130 | * @param array $fields |
||
131 | */ |
||
132 | 24 | public function setFields(array $fields) : void |
|
136 | |||
137 | /** |
||
138 | * Filter input Fields |
||
139 | * |
||
140 | * @param array $data Request |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | 2 | protected function filterData($data) : array |
|
151 | |||
152 | /** |
||
153 | * Filter output Row |
||
154 | * |
||
155 | * @param RowInterface $row from database |
||
156 | * |
||
157 | * @return RowInterface |
||
158 | */ |
||
159 | 2 | protected function filterRow(RowInterface $row) : RowInterface |
|
172 | } |
||
173 |