Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
8 / 9
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
EditTerminNotificationTemplateEndpoint
88.89% covered (warning)
88.89%
8 / 9
0.00% covered (danger)
0.00%
0 / 1
2.01
0.00% covered (danger)
0.00%
0 / 1
 handle
88.89% covered (warning)
88.89%
8 / 9
0.00% covered (danger)
0.00%
0 / 1
2.01
1<?php
2
3namespace Olz\Termine\Endpoints;
4
5use Olz\Api\OlzEditEntityTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @phpstan-import-type OlzTerminNotificationTemplateId from TerminNotificationTemplateEndpointTrait
10 * @phpstan-import-type OlzTerminNotificationTemplateData from TerminNotificationTemplateEndpointTrait
11 *
12 * @extends OlzEditEntityTypedEndpoint<OlzTerminNotificationTemplateId, OlzTerminNotificationTemplateData>
13 */
14class EditTerminNotificationTemplateEndpoint extends OlzEditEntityTypedEndpoint {
15    use TerminNotificationTemplateEndpointTrait;
16
17    protected function handle(mixed $input): mixed {
18        $this->checkPermission('termine');
19
20        $entity = $this->getEntityById($input['id']);
21
22        if (!$this->entityUtils()->canUpdateOlzEntity($entity->getTerminTemplate(), null, 'termine_admin')) {
23            throw new HttpError(403, "Kein Zugriff!");
24        }
25
26        return [
27            'id' => $entity->getId() ?? 0,
28            'meta' => $entity->getTerminTemplate()->getMetaData(),
29            'data' => $this->getEntityData($entity),
30        ];
31    }
32}