Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
91.67% |
11 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
EditTerminLabelEndpoint | |
91.67% |
11 / 12 |
|
50.00% |
1 / 2 |
3.01 | |
0.00% |
0 / 1 |
configure | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
handle | |
90.00% |
9 / 10 |
|
0.00% |
0 / 1 |
2.00 |
1 | <?php |
2 | |
3 | namespace Olz\Termine\Endpoints; |
4 | |
5 | use Olz\Api\OlzEditEntityTypedEndpoint; |
6 | use PhpTypeScriptApi\HttpError; |
7 | |
8 | /** |
9 | * @phpstan-import-type OlzTerminLabelId from TerminLabelEndpointTrait |
10 | * @phpstan-import-type OlzTerminLabelData from TerminLabelEndpointTrait |
11 | * |
12 | * @extends OlzEditEntityTypedEndpoint<OlzTerminLabelId, OlzTerminLabelData> |
13 | */ |
14 | class EditTerminLabelEndpoint extends OlzEditEntityTypedEndpoint { |
15 | use TerminLabelEndpointTrait; |
16 | |
17 | public function configure(): void { |
18 | parent::configure(); |
19 | $this->phpStanUtils->registerTypeImport(TerminLabelEndpointTrait::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, null, 'termine_admin')) { |
28 | throw new HttpError(403, "Kein Zugriff!"); |
29 | } |
30 | |
31 | $this->editUploads($entity); |
32 | |
33 | return [ |
34 | 'id' => $entity->getId() ?? 0, |
35 | 'meta' => $entity->getMetaData(), |
36 | 'data' => $this->getEntityData($entity), |
37 | ]; |
38 | } |
39 | } |