| @@ 133-149 (lines=17) @@ | ||
| 130 | /** |
|
| 131 | * @inheritdoc |
|
| 132 | */ |
|
| 133 | public static function update( |
|
| 134 | array $routeParams, |
|
| 135 | ContainerInterface $container, |
|
| 136 | ServerRequestInterface $request |
|
| 137 | ): ResponseInterface { |
|
| 138 | list ($updated, $index, $api) = static::updateImpl($routeParams, $container, $request); |
|
| 139 | ||
| 140 | $responses = static::createResponses($container, $request); |
|
| 141 | if ($updated > 0) { |
|
| 142 | $modelData = $api->read($index); |
|
| 143 | assert(!($modelData instanceof PaginatedDataInterface)); |
|
| 144 | ||
| 145 | return $responses->getContentResponse($modelData); |
|
| 146 | } |
|
| 147 | ||
| 148 | return $responses->getCodeResponse(404); |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * @inheritdoc |
|
| @@ 346-376 (lines=31) @@ | ||
| 343 | * |
|
| 344 | * @return ResponseInterface |
|
| 345 | */ |
|
| 346 | protected static function updateInRelationship( |
|
| 347 | $parentIndex, |
|
| 348 | string $relationshipName, |
|
| 349 | $childIndex, |
|
| 350 | array $attributes, |
|
| 351 | array $toMany, |
|
| 352 | string $childApiClass, |
|
| 353 | ContainerInterface $container, |
|
| 354 | ServerRequestInterface $request |
|
| 355 | ): ResponseInterface { |
|
| 356 | /** @var CrudInterface $childApi */ |
|
| 357 | list ($updated, $childApi) = static::updateInRelationshipImpl( |
|
| 358 | $parentIndex, |
|
| 359 | $relationshipName, |
|
| 360 | $childIndex, |
|
| 361 | $attributes, |
|
| 362 | $toMany, |
|
| 363 | $childApiClass, |
|
| 364 | $container |
|
| 365 | ); |
|
| 366 | ||
| 367 | $responses = static::createResponses($container, $request); |
|
| 368 | if ($updated > 0) { |
|
| 369 | $modelData = $childApi->read($childIndex); |
|
| 370 | assert(!($modelData instanceof PaginatedDataInterface)); |
|
| 371 | ||
| 372 | return $responses->getContentResponse($modelData); |
|
| 373 | } |
|
| 374 | ||
| 375 | return $responses->getCodeResponse(404); |
|
| 376 | } |
|
| 377 | ||
| 378 | /** |
|
| 379 | * @param ContainerInterface $container |
|