Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DeleteWeeklyPictureEndpoint
100.00% covered (success)
100.00%
11 / 11
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%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Olz\Startseite\Endpoints;
4
5use Olz\Api\OlzDeleteEntityTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @phpstan-import-type OlzWeeklyPictureId from WeeklyPictureEndpointTrait
10 * @phpstan-import-type OlzWeeklyPictureData from WeeklyPictureEndpointTrait
11 *
12 * @extends OlzDeleteEntityTypedEndpoint<OlzWeeklyPictureId, OlzWeeklyPictureData>
13 */
14class DeleteWeeklyPictureEndpoint extends OlzDeleteEntityTypedEndpoint {
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->entityUtils()->updateOlzEntity($entity, ['onOff' => false]);
33        $this->entityManager()->persist($entity);
34        $this->entityManager()->flush();
35
36        return [];
37    }
38}