| Conditions | 1 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 4 | public static function build(): iterable |
|
| 16 | { |
||
| 17 | 1 | yield 'terminateBooking' => fn () => [ |
|
| 18 | 1 | 'type' => Type::nonNull(_types()->getOutput(Booking::class)), |
|
| 19 | 1 | 'description' => 'Terminate a booking', |
|
| 20 | 1 | 'args' => [ |
|
| 21 | 1 | 'id' => Type::nonNull(_types()->getId(Booking::class)), |
|
| 22 | 1 | 'comment' => Type::string(), |
|
| 23 | 1 | ], |
|
| 24 | 1 | 'resolve' => function ($root, array $args, SessionInterface $session): Booking { |
|
| 25 | /** @var Booking $booking */ |
||
| 26 | 4 | $booking = $args['id']->getEntity(); |
|
| 27 | |||
| 28 | // Check ACL |
||
| 29 | 4 | Helper::throwIfDenied($booking, 'update'); |
|
| 30 | |||
| 31 | 3 | $booking->terminate($args['comment'] ?? null); |
|
| 32 | 3 | _em()->flush(); |
|
| 33 | |||
| 34 | 3 | return $booking; |
|
| 35 | 1 | }, |
|
| 39 |