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