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