@@ 251-265 (lines=15) @@ | ||
248 | /** |
|
249 | * @inheritDoc |
|
250 | */ |
|
251 | public function createItem($tableName, array $data) |
|
252 | { |
|
253 | $tableGateway = $this->getTableGateway($tableName); |
|
254 | $data = $this->processData($tableName, $data); |
|
255 | ||
256 | foreach($data as $key => $value) { |
|
257 | if ($value instanceof File) { |
|
258 | $data[$key] = $this->processFile($value); |
|
259 | } |
|
260 | } |
|
261 | ||
262 | $newRecord = $tableGateway->manageRecordUpdate($tableName, $data); |
|
263 | ||
264 | return $this->getItem($tableName, $newRecord[$tableGateway->primaryKeyFieldName]); |
|
265 | } |
|
266 | ||
267 | /** |
|
268 | * @inheritDoc |
|
@@ 270-284 (lines=15) @@ | ||
267 | /** |
|
268 | * @inheritDoc |
|
269 | */ |
|
270 | public function updateItem($tableName, $id, array $data) |
|
271 | { |
|
272 | $tableGateway = $this->getTableGateway($tableName); |
|
273 | $data = $this->processData($tableName, $data); |
|
274 | ||
275 | foreach($data as $key => $value) { |
|
276 | if ($value instanceof File) { |
|
277 | $data[$key] = $this->processFile($value); |
|
278 | } |
|
279 | } |
|
280 | ||
281 | $updatedRecord = $tableGateway->manageRecordUpdate($tableName, array_merge($data, ['id' => $id])); |
|
282 | ||
283 | return $this->getItem($tableName, $updatedRecord[$tableGateway->primaryKeyFieldName]); |
|
284 | } |
|
285 | ||
286 | /** |
|
287 | * @inheritDoc |