Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
DeleteKarteEndpoint | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
configure | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
handle | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 |
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 | public function configure(): void { |
21 | parent::configure(); |
22 | $this->phpStanUtils->registerTypeImport(KarteEndpointTrait::class); |
23 | } |
24 | |
25 | protected function handle(mixed $input): mixed { |
26 | $this->checkPermission('any'); |
27 | |
28 | $entity = $this->getEntityById($input['id']); |
29 | |
30 | if (!$this->entityUtils()->canUpdateOlzEntity($entity, null, 'karten')) { |
31 | throw new HttpError(403, "Kein Zugriff!"); |
32 | } |
33 | |
34 | $this->entityUtils()->updateOlzEntity($entity, ['onOff' => false]); |
35 | $this->entityManager()->persist($entity); |
36 | $this->entityManager()->flush(); |
37 | |
38 | return []; |
39 | } |
40 | } |