Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MailTemplates | |
0.00% |
0 / 54 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| readResponse | |
0.00% |
0 / 54 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Zmsentities\Config as Entity; |
| 11 | |
| 12 | class MailTemplates extends BaseController |
| 13 | { |
| 14 | /** |
| 15 | * @SuppressWarnings(Param) |
| 16 | * @return String |
| 17 | */ |
| 18 | public function readResponse( |
| 19 | \Psr\Http\Message\RequestInterface $request, |
| 20 | \Psr\Http\Message\ResponseInterface $response, |
| 21 | array $args |
| 22 | ) { |
| 23 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 24 | $providerId = $workstation->scope['provider']['id']; |
| 25 | |
| 26 | $scopeName = $workstation->scope['contact']['name']; |
| 27 | $scopeId = $workstation->scope['id']; |
| 28 | |
| 29 | if (isset($args['scopeId']) && !empty($args['scopeId'])) { |
| 30 | $scope = \App::$http |
| 31 | ->readGetResult('/scope/' . $args['scopeId'] . '/', ['resolveReferences' => 1]) |
| 32 | ->getEntity(); |
| 33 | |
| 34 | $scopeName = $scope->contact->name; |
| 35 | $scopeId = $scope->id; |
| 36 | $providerId = $scope->provider->id; |
| 37 | } |
| 38 | |
| 39 | $config = \App::$http->readGetResult('/config/')->getEntity(); |
| 40 | |
| 41 | $mergedMailTemplates = \App::$http->readGetResult('/merged-mailtemplates/' . $providerId . '/')->getCollection(); |
| 42 | foreach ($mergedMailTemplates as $template) { |
| 43 | if ($template['provider']) { |
| 44 | $template->isCustom = true; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | $priorityNames = [ |
| 49 | 'mail_preconfirmed.twig', |
| 50 | 'mail_confirmation.twig', |
| 51 | 'mail_reminder.twig', |
| 52 | 'mail_delete.twig' |
| 53 | ]; |
| 54 | |
| 55 | $mergedMailTemplates->prioritizeByName($priorityNames); |
| 56 | |
| 57 | $mainProcessExample = ((new \BO\Zmsentities\Process())->getExample()); |
| 58 | $mainProcessExample->id = 987654; |
| 59 | $dateTime = new \DateTimeImmutable("2015-10-23 08:00:00", new \DateTimeZone('Europe/Berlin')); |
| 60 | $mainProcessExample->getFirstAppointment()->setDateTime($dateTime); |
| 61 | $mainProcessExample->requests[] = (new \BO\Zmsentities\Request())->getExample(); |
| 62 | |
| 63 | $processExample = ((new \BO\Zmsentities\Process())->getExample()); |
| 64 | $processExample->scope = ((new \BO\Zmsentities\Scope())->getExample()); |
| 65 | $processExample2 = clone $processExample; |
| 66 | $dateTime = new \DateTimeImmutable("2015-12-30 11:55:00", new \DateTimeZone('Europe/Berlin')); |
| 67 | $processExample2->getFirstAppointment()->setDateTime($dateTime); |
| 68 | |
| 69 | $processListExample = new \BO\Zmsentities\Collection\ProcessList(); |
| 70 | $processListExample->addEntity($processExample); |
| 71 | $processListExample->addEntity($processExample2); |
| 72 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
| 73 | |
| 74 | return \BO\Slim\Render::withHtml( |
| 75 | $response, |
| 76 | 'page/mailtemplates.twig', |
| 77 | array( |
| 78 | 'title' => 'Konfiguration System', |
| 79 | 'pageTitle' => 'Mail Templates für ' . $scopeName, |
| 80 | 'providerId' => $providerId, |
| 81 | 'workstation' => $workstation, |
| 82 | 'config' => $config, |
| 83 | 'scopeId' => $scopeId, |
| 84 | 'mailtemplates' => $mergedMailTemplates, |
| 85 | 'processExample' => $mainProcessExample, |
| 86 | 'processListExample' => $processListExample, |
| 87 | 'menuActive' => 'mailtemplates', |
| 88 | 'success' => $success |
| 89 | ) |
| 90 | ); |
| 91 | } |
| 92 | } |