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