@@ 206-220 (lines=15) @@ | ||
203 | /** |
|
204 | * @inheritDoc |
|
205 | */ |
|
206 | public function createItem($tableName, array $data) |
|
207 | { |
|
208 | $tableGateway = $this->getTableGateway($tableName); |
|
209 | $data = $this->processData($tableName, $data); |
|
210 | ||
211 | foreach($data as $key => $value) { |
|
212 | if ($value instanceof File) { |
|
213 | $data[$key] = $this->processFile($value); |
|
214 | } |
|
215 | } |
|
216 | ||
217 | $newRecord = $tableGateway->manageRecordUpdate($tableName, $data); |
|
218 | ||
219 | return $this->getItem($tableName, $newRecord[$tableGateway->primaryKeyFieldName]); |
|
220 | } |
|
221 | ||
222 | /** |
|
223 | * @inheritDoc |
|
@@ 225-239 (lines=15) @@ | ||
222 | /** |
|
223 | * @inheritDoc |
|
224 | */ |
|
225 | public function updateItem($tableName, $id, array $data) |
|
226 | { |
|
227 | $tableGateway = $this->getTableGateway($tableName); |
|
228 | $data = $this->processData($tableName, $data); |
|
229 | ||
230 | foreach($data as $key => $value) { |
|
231 | if ($value instanceof File) { |
|
232 | $data[$key] = $this->processFile($value); |
|
233 | } |
|
234 | } |
|
235 | ||
236 | $updatedRecord = $tableGateway->manageRecordUpdate($tableName, array_merge($data, ['id' => $id])); |
|
237 | ||
238 | return $this->getItem($tableName, $updatedRecord[$tableGateway->primaryKeyFieldName]); |
|
239 | } |
|
240 | ||
241 | /** |
|
242 | * @inheritDoc |