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