Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
OrganisationHash | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
11 / 11 |
|
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\Zmsapi; |
9 | |
10 | use BO\Slim\Render; |
11 | use BO\Mellon\Validator; |
12 | use BO\Zmsdb\Ticketprinter as Ticketprinter; |
13 | use BO\Zmsdb\Organisation as Query; |
14 | |
15 | class OrganisationHash extends BaseController |
16 | { |
17 | /** |
18 | * @SuppressWarnings(Param) |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | \BO\Zmsdb\Connection\Select::getWriteConnection(); |
27 | $organisation = (new Query())->readEntity($args['id']); |
28 | if (! $organisation) { |
29 | throw new Exception\Organisation\OrganisationNotFound(); |
30 | } |
31 | //$ticketprinterName = Validator::param('name')->isString()->setDefault('')->getValue(); |
32 | $ticketprinterName = "Ticket Printer for " . $organisation->name; |
33 | $ticketprinter = (new Ticketprinter())->writeEntityWithHash($organisation->id, $ticketprinterName); |
34 | |
35 | $message = Response\Message::create($request); |
36 | $message->data = $ticketprinter; |
37 | |
38 | $response = Render::withLastModified($response, time(), '0'); |
39 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
40 | return $response; |
41 | } |
42 | } |