Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
DeleteQuestionCategoryEndpoint
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
3.01
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
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
2.01
1<?php
2
3namespace Olz\Faq\Endpoints;
4
5use Olz\Api\OlzDeleteEntityTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @phpstan-import-type OlzQuestionCategoryId from QuestionCategoryEndpointTrait
10 * @phpstan-import-type OlzQuestionCategoryData from QuestionCategoryEndpointTrait
11 *
12 * @extends OlzDeleteEntityTypedEndpoint<OlzQuestionCategoryId, OlzQuestionCategoryData>
13 */
14class DeleteQuestionCategoryEndpoint extends OlzDeleteEntityTypedEndpoint {
15    use QuestionCategoryEndpointTrait;
16
17    public function configure(): void {
18        parent::configure();
19        $this->phpStanUtils->registerTypeImport(QuestionCategoryEndpointTrait::class);
20    }
21
22    protected function handle(mixed $input): mixed {
23        $this->checkPermission('faq');
24
25        $entity = $this->getEntityById($input['id']);
26
27        if (!$this->entityUtils()->canUpdateOlzEntity($entity, null, 'faq')) {
28            throw new HttpError(403, "Kein Zugriff!");
29        }
30
31        $this->entityUtils()->updateOlzEntity($entity, ['onOff' => false]);
32        $this->entityManager()->persist($entity);
33        $this->entityManager()->flush();
34
35        return [];
36    }
37}