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