Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
32 / 32 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ProcessDelete | |
100.00% |
32 / 32 |
|
100.00% |
2 / 2 |
7 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
| writeDeleteMailNotifications | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsadmin |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsadmin; |
| 11 | |
| 12 | use BO\Mellon\Validator; |
| 13 | use BO\Slim\Render; |
| 14 | |
| 15 | /** |
| 16 | * Delete a process |
| 17 | */ |
| 18 | class ProcessDelete extends BaseController |
| 19 | { |
| 20 | /** |
| 21 | * @SuppressWarnings(Param) |
| 22 | * @return String |
| 23 | */ |
| 24 | public function readResponse( |
| 25 | \Psr\Http\Message\RequestInterface $request, |
| 26 | \Psr\Http\Message\ResponseInterface $response, |
| 27 | array $args |
| 28 | ) { |
| 29 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 30 | $processId = Validator::value($args['id'])->isNumber()->getValue(); |
| 31 | $initiator = Validator::param('initiator')->isString()->getValue(); |
| 32 | $process = \App::$http->readGetResult('/process/' . $processId . '/')->getEntity(); |
| 33 | $process->status = 'deleted'; |
| 34 | $workstation->validateProcessScopeAccess((new Helper\ClusterHelper($workstation))->getScopeList(), $process); |
| 35 | |
| 36 | \App::$http->readDeleteResult('/process/' . $process->getId() . '/', ['initiator' => $initiator]); |
| 37 | static::writeDeleteMailNotifications($process); |
| 38 | |
| 39 | return \BO\Slim\Render::withHtml( |
| 40 | $response, |
| 41 | 'element/helper/messageHandler.twig', |
| 42 | array( |
| 43 | 'success' => 'process_deleted', |
| 44 | 'selectedprocess' => $process, |
| 45 | ) |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | public static function writeDeleteMailNotifications($process) |
| 50 | { |
| 51 | #email only for clients with appointment if email address is given |
| 52 | if ( |
| 53 | $process->getFirstClient()->hasEmail() && |
| 54 | $process->isWithAppointment() && |
| 55 | $process->scope->hasEmailFrom() |
| 56 | ) { |
| 57 | \App::$http |
| 58 | ->readPostResult( |
| 59 | '/process/' . $process->getId() . '/' . $process->getAuthKey() . '/delete/mail/', |
| 60 | $process, |
| 61 | ['initiator' => 'admin'] |
| 62 | )->getEntity(); |
| 63 | } |
| 64 | #sms notifications for clients with and without appointment if telephone number is given |
| 65 | if ( |
| 66 | $process->scope->hasNotificationEnabled() && |
| 67 | $process->getFirstClient()->hasTelephone() |
| 68 | ) { |
| 69 | \App::$http |
| 70 | ->readPostResult( |
| 71 | '/process/' . $process->getId() . '/' . $process->getAuthKey() . '/delete/notification/', |
| 72 | $process |
| 73 | )->getEntity(); |
| 74 | } |
| 75 | } |
| 76 | } |