| @@ 135-151 (lines=17) @@ | ||
| 132 | /** |
|
| 133 | * @inheritdoc |
|
| 134 | */ |
|
| 135 | public static function update( |
|
| 136 | array $routeParams, |
|
| 137 | ContainerInterface $container, |
|
| 138 | ServerRequestInterface $request |
|
| 139 | ): ResponseInterface { |
|
| 140 | list ($updated, $index, $api) = static::updateImpl($routeParams, $container, $request); |
|
| 141 | ||
| 142 | $responses = static::createResponses($container, $request); |
|
| 143 | if ($updated > 0) { |
|
| 144 | $modelData = $api->read($index); |
|
| 145 | assert(!($modelData instanceof PaginatedDataInterface)); |
|
| 146 | ||
| 147 | return $responses->getContentResponse($modelData); |
|
| 148 | } |
|
| 149 | ||
| 150 | return $responses->getCodeResponse(404); |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * @inheritdoc |
|
| @@ 368-398 (lines=31) @@ | ||
| 365 | * @throws ContainerExceptionInterface |
|
| 366 | * @throws NotFoundExceptionInterface |
|
| 367 | */ |
|
| 368 | protected static function updateInRelationship( |
|
| 369 | $parentIndex, |
|
| 370 | string $relationshipName, |
|
| 371 | $childIndex, |
|
| 372 | array $attributes, |
|
| 373 | array $toMany, |
|
| 374 | string $childApiClass, |
|
| 375 | ContainerInterface $container, |
|
| 376 | ServerRequestInterface $request |
|
| 377 | ): ResponseInterface { |
|
| 378 | /** @var CrudInterface $childApi */ |
|
| 379 | list ($updated, $childApi) = static::updateInRelationshipImpl( |
|
| 380 | $parentIndex, |
|
| 381 | $relationshipName, |
|
| 382 | $childIndex, |
|
| 383 | $attributes, |
|
| 384 | $toMany, |
|
| 385 | $childApiClass, |
|
| 386 | $container |
|
| 387 | ); |
|
| 388 | ||
| 389 | $responses = static::createResponses($container, $request); |
|
| 390 | if ($updated > 0) { |
|
| 391 | $modelData = $childApi->read($childIndex); |
|
| 392 | assert(!($modelData instanceof PaginatedDataInterface)); |
|
| 393 | ||
| 394 | return $responses->getContentResponse($modelData); |
|
| 395 | } |
|
| 396 | ||
| 397 | return $responses->getCodeResponse(404); |
|
| 398 | } |
|
| 399 | ||
| 400 | /** |
|
| 401 | * @param ContainerInterface $container |
|