Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
CreateBookingEndpoint | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
handle | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Apps\Anmelden\Endpoints; |
4 | |
5 | use Olz\Api\OlzCreateEntityTypedEndpoint; |
6 | use Olz\Entity\Anmelden\Booking; |
7 | |
8 | /** |
9 | * @phpstan-import-type OlzBookingId from BookingEndpointTrait |
10 | * @phpstan-import-type OlzBookingData from BookingEndpointTrait |
11 | * |
12 | * @extends OlzCreateEntityTypedEndpoint<OlzBookingId, OlzBookingData> |
13 | */ |
14 | class CreateBookingEndpoint extends OlzCreateEntityTypedEndpoint { |
15 | use BookingEndpointTrait; |
16 | |
17 | protected function handle(mixed $input): mixed { |
18 | $booking = new Booking(); |
19 | $this->entityUtils()->createOlzEntity($booking, $input['meta']); |
20 | $this->updateEntityWithData($booking, $input['data']); |
21 | |
22 | $this->entityManager()->persist($booking); |
23 | $this->entityManager()->flush(); |
24 | |
25 | $internal_booking_id = $booking->getId() ?? 0; |
26 | $external_booking_id = $this->idUtils()->toExternalId($internal_booking_id, 'Booking') ?: '-'; |
27 | |
28 | return [ |
29 | 'id' => $external_booking_id, |
30 | ]; |
31 | } |
32 | } |