| @@ 230-244 (lines=15) @@ | ||
| 227 | /** |
|
| 228 | * @inheritDoc |
|
| 229 | */ |
|
| 230 | public function createItem($tableName, array $data) |
|
| 231 | { |
|
| 232 | $tableGateway = $this->getTableGateway($tableName); |
|
| 233 | $data = $this->processData($tableName, $data); |
|
| 234 | ||
| 235 | foreach($data as $key => $value) { |
|
| 236 | if ($value instanceof File) { |
|
| 237 | $data[$key] = $this->processFile($value); |
|
| 238 | } |
|
| 239 | } |
|
| 240 | ||
| 241 | $newRecord = $tableGateway->manageRecordUpdate($tableName, $data); |
|
| 242 | ||
| 243 | return $this->getItem($tableName, $newRecord[$tableGateway->primaryKeyFieldName]); |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * @inheritDoc |
|
| @@ 249-263 (lines=15) @@ | ||
| 246 | /** |
|
| 247 | * @inheritDoc |
|
| 248 | */ |
|
| 249 | public function updateItem($tableName, $id, array $data) |
|
| 250 | { |
|
| 251 | $tableGateway = $this->getTableGateway($tableName); |
|
| 252 | $data = $this->processData($tableName, $data); |
|
| 253 | ||
| 254 | foreach($data as $key => $value) { |
|
| 255 | if ($value instanceof File) { |
|
| 256 | $data[$key] = $this->processFile($value); |
|
| 257 | } |
|
| 258 | } |
|
| 259 | ||
| 260 | $updatedRecord = $tableGateway->manageRecordUpdate($tableName, array_merge($data, ['id' => $id])); |
|
| 261 | ||
| 262 | return $this->getItem($tableName, $updatedRecord[$tableGateway->primaryKeyFieldName]); |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * @inheritDoc |
|