Lines
100.00%
14 / 14
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| OrganisationDelete | 100.00% | 14 / 14 | 100.00% | 1 / 1 | 2 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 14 / 14 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package ZMS API | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | */ | |
| 7 | ||
| 8 | namespace BO\Zmsbackend\Organisation\Api; | |
| 9 | ||
| 10 | use BO\Slim\Render; | |
| 11 | use BO\Zmsbackend\Organisation\Service\Organisation as Query; | |
| 12 | ||
| 13 | /** | |
| 14 | * Delete an organisation by Id | |
| 15 | */ | |
| 16 | class OrganisationDelete extends \BO\Zmsbackend\Api\BaseController | |
| 17 | { | |
| 18 | /** | |
| 19 | * @SuppressWarnings(Param) | |
| 20 | * @return \Psr\Http\Message\ResponseInterface | |
| 21 | */ | |
| 22 | #[\Override] | |
| 23 | public function readResponse( | |
| 24 | \Psr\Http\Message\RequestInterface $request, | |
| 25 | \Psr\Http\Message\ResponseInterface $response, | |
| 26 | array $args | |
| 27 | ) { | |
| 28 | $query = new Query(); | |
| 29 | $organisation = $query->readEntity($args['id'], 1); | |
| 30 | if (! $organisation) { | |
| 31 | throw new \BO\Zmsbackend\Organisation\Exception\OrganisationNotFound(); | |
| 32 | }(new \BO\Zmsbackend\Helper\User($request, 2))->checkPermissions( | |
| 33 | 'organisation', | |
| 34 | new \BO\Zmsentities\Useraccount\EntityAccess($organisation) | |
| 35 | ); | |
| 36 | $query->deleteEntity($organisation->id); | |
| 37 | ||
| 38 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 39 | $message->data = $organisation; | |
| 40 | ||
| 41 | $response = Render::withLastModified($response, time(), '0'); | |
| 42 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); | |
| 43 | return $response; | |
| 44 | } | |
| 45 | } |