Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| EditKarteEndpoint | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| handle | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Karten\Endpoints; |
| 4 | |
| 5 | use Olz\Api\OlzEditEntityTypedEndpoint; |
| 6 | use PhpTypeScriptApi\HttpError; |
| 7 | |
| 8 | /** |
| 9 | * @phpstan-import-type OlzKarteId from KarteEndpointTrait |
| 10 | * @phpstan-import-type OlzKarteData from KarteEndpointTrait |
| 11 | * |
| 12 | * TODO: Those should not be necessary! |
| 13 | * @phpstan-import-type OlzKarteKind from KarteEndpointTrait |
| 14 | * |
| 15 | * @extends OlzEditEntityTypedEndpoint<OlzKarteId, OlzKarteData> |
| 16 | */ |
| 17 | class EditKarteEndpoint extends OlzEditEntityTypedEndpoint { |
| 18 | use KarteEndpointTrait; |
| 19 | |
| 20 | protected function handle(mixed $input): mixed { |
| 21 | $this->checkPermission('any'); |
| 22 | |
| 23 | $entity = $this->getEntityById($input['id']); |
| 24 | |
| 25 | if (!$this->entityUtils()->canUpdateOlzEntity($entity, null, 'karten')) { |
| 26 | throw new HttpError(403, "Kein Zugriff!"); |
| 27 | } |
| 28 | |
| 29 | $this->editUploads($entity); |
| 30 | |
| 31 | return [ |
| 32 | 'id' => $entity->getId() ?? 0, |
| 33 | 'meta' => $entity->getMetaData(), |
| 34 | 'data' => $this->getEntityData($entity), |
| 35 | ]; |
| 36 | } |
| 37 | } |