| @@ 263-277 (lines=15) @@ | ||
| 260 | /** |
|
| 261 | * @inheritDoc |
|
| 262 | */ |
|
| 263 | public function createItem($tableName, array $data) |
|
| 264 | { |
|
| 265 | $tableGateway = $this->getTableGateway($tableName); |
|
| 266 | $data = $this->processData($tableName, $data); |
|
| 267 | ||
| 268 | foreach($data as $key => $value) { |
|
| 269 | if ($value instanceof File) { |
|
| 270 | $data[$key] = $this->processFile($value); |
|
| 271 | } |
|
| 272 | } |
|
| 273 | ||
| 274 | $newRecord = $tableGateway->manageRecordUpdate($tableName, $data); |
|
| 275 | ||
| 276 | return $this->getItem($tableName, $newRecord[$tableGateway->primaryKeyFieldName]); |
|
| 277 | } |
|
| 278 | ||
| 279 | /** |
|
| 280 | * @inheritDoc |
|
| @@ 282-296 (lines=15) @@ | ||
| 279 | /** |
|
| 280 | * @inheritDoc |
|
| 281 | */ |
|
| 282 | public function updateItem($tableName, $id, array $data) |
|
| 283 | { |
|
| 284 | $tableGateway = $this->getTableGateway($tableName); |
|
| 285 | $data = $this->processData($tableName, $data); |
|
| 286 | ||
| 287 | foreach($data as $key => $value) { |
|
| 288 | if ($value instanceof File) { |
|
| 289 | $data[$key] = $this->processFile($value); |
|
| 290 | } |
|
| 291 | } |
|
| 292 | ||
| 293 | $updatedRecord = $tableGateway->manageRecordUpdate($tableName, array_merge($data, ['id' => $id])); |
|
| 294 | ||
| 295 | return $this->getItem($tableName, $updatedRecord[$tableGateway->primaryKeyFieldName]); |
|
| 296 | } |
|
| 297 | ||
| 298 | /** |
|
| 299 | * @inheritDoc |
|