Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CreateKarteEndpoint
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Olz\Karten\Endpoints;
4
5use Olz\Api\OlzCreateEntityTypedEndpoint;
6use Olz\Entity\Karten\Karte;
7
8/**
9 * @phpstan-import-type OlzKarteId from KarteEndpointTrait
10 * @phpstan-import-type OlzKarteData from KarteEndpointTrait
11 *
12 * TODO: Those should not be necessary!
13 * @phpstan-import-type OlzKarteKind from KarteEndpointTrait
14 *
15 * @extends OlzCreateEntityTypedEndpoint<OlzKarteId, OlzKarteData>
16 */
17class CreateKarteEndpoint extends OlzCreateEntityTypedEndpoint {
18    use KarteEndpointTrait;
19
20    protected function handle(mixed $input): mixed {
21        $this->checkPermission('karten');
22
23        $entity = new Karte();
24        $this->entityUtils()->createOlzEntity($entity, $input['meta']);
25        $this->updateEntityWithData($entity, $input['data']);
26
27        $this->entityManager()->persist($entity);
28        $this->entityManager()->flush();
29        $this->persistUploads($entity, $input['data']);
30
31        return [
32            'id' => $entity->getId() ?? 0,
33        ];
34    }
35}