Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
EditWeeklyPictureEndpoint
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Olz\Startseite\Endpoints;
4
5use Olz\Api\OlzEditEntityTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @phpstan-import-type OlzWeeklyPictureId from WeeklyPictureEndpointTrait
10 * @phpstan-import-type OlzWeeklyPictureData from WeeklyPictureEndpointTrait
11 *
12 * @extends OlzEditEntityTypedEndpoint<OlzWeeklyPictureId, OlzWeeklyPictureData>
13 */
14class EditWeeklyPictureEndpoint extends OlzEditEntityTypedEndpoint {
15    use WeeklyPictureEndpointTrait;
16
17    public function configure(): void {
18        parent::configure();
19        $this->configureWeeklyPictureEndpointTrait();
20        $this->phpStanUtils->registerTypeImport(WeeklyPictureEndpointTrait::class);
21    }
22
23    protected function handle(mixed $input): mixed {
24        $this->checkPermission('any');
25
26        $entity = $this->getEntityById($input['id']);
27
28        if (!$this->entityUtils()->canUpdateOlzEntity($entity, null, 'weekly_picture')) {
29            throw new HttpError(403, "Kein Zugriff!");
30        }
31
32        $this->editUploads($entity);
33
34        return [
35            'id' => $entity->getId() ?? 0,
36            'meta' => $entity->getMetaData(),
37            'data' => $this->getEntityData($entity),
38        ];
39    }
40}