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