Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
92.31% |
12 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MailAdd | |
92.31% |
12 / 13 |
|
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
| readResponse | |
92.31% |
12 / 13 |
|
0.00% |
0 / 1 |
2.00 | |||
| 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\Mail as Query; |
| 12 | use BO\Mellon\Validator; |
| 13 | |
| 14 | class MailAdd extends BaseController |
| 15 | { |
| 16 | /** |
| 17 | * @SuppressWarnings(Param) |
| 18 | * @return String |
| 19 | */ |
| 20 | public function readResponse( |
| 21 | \Psr\Http\Message\RequestInterface $request, |
| 22 | \Psr\Http\Message\ResponseInterface $response, |
| 23 | array $args |
| 24 | ) { |
| 25 | (new Helper\User($request))->checkRights('basic'); |
| 26 | |
| 27 | $input = Validator::input()->isJson()->assertValid()->getValue(); |
| 28 | $entity = new \BO\Zmsentities\Mail($input); |
| 29 | $entity->testValid(); |
| 30 | |
| 31 | $process = new \BO\Zmsentities\Process($entity->process); |
| 32 | |
| 33 | $mail = (new Query())->writeInQueue($entity, \App::$now); |
| 34 | $message = Response\Message::create($request); |
| 35 | $message->data = $mail; |
| 36 | |
| 37 | if ($process->shouldSendAdminMailOnClerkMail()) { |
| 38 | (new \BO\Zmsdb\Mail())->writeInQueueWithAdmin($entity); |
| 39 | } |
| 40 | |
| 41 | $response = Render::withLastModified($response, time(), '0'); |
| 42 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
| 43 | return $response; |
| 44 | } |
| 45 | } |