Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
UpdateTerminLocationEndpoint
92.86% covered (success)
92.86%
13 / 14
50.00% covered (danger)
50.00%
1 / 2
3.00
0.00% covered (danger)
0.00%
0 / 1
 configure
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 handle
91.67% covered (success)
91.67%
11 / 12
0.00% covered (danger)
0.00%
0 / 1
2.00
1<?php
2
3namespace Olz\Termine\Endpoints;
4
5use Olz\Api\OlzUpdateEntityTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @phpstan-import-type OlzTerminLocationId from TerminLocationEndpointTrait
10 * @phpstan-import-type OlzTerminLocationData from TerminLocationEndpointTrait
11 *
12 * @extends OlzUpdateEntityTypedEndpoint<OlzTerminLocationId, OlzTerminLocationData>
13 */
14class UpdateTerminLocationEndpoint extends OlzUpdateEntityTypedEndpoint {
15    use TerminLocationEndpointTrait;
16
17    public function configure(): void {
18        parent::configure();
19        $this->phpStanUtils->registerTypeImport(TerminLocationEndpointTrait::class);
20    }
21
22    protected function handle(mixed $input): mixed {
23        $this->checkPermission('termine');
24
25        $entity = $this->getEntityById($input['id']);
26
27        if (!$this->entityUtils()->canUpdateOlzEntity($entity, $input['meta'], 'termine_admin')) {
28            throw new HttpError(403, "Kein Zugriff!");
29        }
30
31        $this->entityUtils()->updateOlzEntity($entity, $input['meta']);
32        $this->updateEntityWithData($entity, $input['data']);
33
34        $this->entityManager()->persist($entity);
35        $this->entityManager()->flush();
36        $this->persistUploads($entity);
37
38        return [
39            'id' => $entity->getId() ?? 0,
40        ];
41    }
42}