Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
DeleteKarteEndpoint | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
handle | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Olz\Karten\Endpoints; |
4 | |
5 | use Olz\Api\OlzDeleteEntityTypedEndpoint; |
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 OlzDeleteEntityTypedEndpoint<OlzKarteId, OlzKarteData> |
16 | */ |
17 | class DeleteKarteEndpoint extends OlzDeleteEntityTypedEndpoint { |
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->entityUtils()->updateOlzEntity($entity, ['onOff' => false]); |
30 | $this->entityManager()->persist($entity); |
31 | $this->entityManager()->flush(); |
32 | |
33 | return []; |
34 | } |
35 | } |