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