Lines
65.00%
13 / 20
Methods
50.00%
1 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 58.82% | 10 / 17 | 0.00% | 0 / 1 | 5.12 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 19 | class AvailabilityDelete extends \BO\Zmsbackend\Api\BaseController | |
| 20 | { | |
| 21 | /** | |
| 22 | * @SuppressWarnings(Param) | |
| 23 | * @return ResponseInterface | |
| 24 | */ | |
| 25 | #[\Override] | |
| 26 | public function readResponse( | |
| 27 | RequestInterface $request, | |
| 28 | ResponseInterface $response, | |
| 29 | array $args | |
| 30 | ): ResponseInterface { | |
| 31 | (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('availability'); | |
| 32 | $repository = new AvailabilityRepository(); | |
| 33 | $entity = $repository->readEntity($args['id'], 2); | |
| 34 | ||
| 35 | if ($entity->scope && $entity->hasId() && $repository->deleteEntity($entity->getId())) { | |
| 36 | (new AvailabilityHistoryService())->writeDeleted($entity); | |
| 37 | (new CalculateSlotsHelper(\App::DEBUG))->writePostProcessingByScope($entity->scope, \App::$now); | |
| 38 | App::$log->info('Deleted availability', [ | |
| 39 | 'id' => $entity->getId(), | |
| 40 | 'scope_id' => $entity->scope['id'], | |
| 41 | 'operation' => 'delete' | |
| 42 | ]); | |
| 43 | } else { | |
| 44 | $entity = new Entity(['id' => $args['id']]); | |
| 45 | } | |
| 46 | ||
| 47 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 48 | $message->data = $entity; | |
| 49 | ||
| 50 | $response = Render::withLastModified($response, time(), '0'); | |
| 51 | $response = Render::withJson($response, $message->setUpdatedMetaData(), 200); | |
| 52 | return $response; | |
| 53 | } | |
| 54 | } |
Inherited from BO\Zmsbackend\Api\BaseController
| 20 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) | |
| 21 | { | |
| 22 | $request = $this->initRequest($request); | |
| 23 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); | |
| 24 | return $this->readResponse($request, $noCacheResponse, $args); | |
| 25 | } |