Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateQuestionEndpoint
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Faq\Endpoints;
4
5use Olz\Api\OlzCreateEntityTypedEndpoint;
6use Olz\Entity\Faq\Question;
7
8/**
9 * @phpstan-import-type OlzQuestionId from QuestionEndpointTrait
10 * @phpstan-import-type OlzQuestionData from QuestionEndpointTrait
11 *
12 * @extends OlzCreateEntityTypedEndpoint<OlzQuestionId, OlzQuestionData>
13 */
14class CreateQuestionEndpoint extends OlzCreateEntityTypedEndpoint {
15    use QuestionEndpointTrait;
16
17    protected function handle(mixed $input): mixed {
18        $this->checkPermission('faq');
19
20        $entity = new Question();
21        $this->entityUtils()->createOlzEntity($entity, $input['meta']);
22        $this->updateEntityWithData($entity, $input['data']);
23
24        $this->entityManager()->persist($entity);
25        $this->entityManager()->flush();
26        $this->persistUploads($entity, $input['data']);
27
28        return [
29            'id' => $entity->getId() ?? 0,
30        ];
31    }
32}