Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ProcessDelete
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
2 / 2
7
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
1 / 1
1
 writeDeleteMailNotifications
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
6
1<?php
2
3/**
4 *
5 * @package Zmsadmin
6 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
7 *
8 */
9
10namespace BO\Zmsadmin;
11
12use BO\Mellon\Validator;
13use BO\Slim\Render;
14
15/**
16 * Delete a process
17 */
18class 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->testMatchingProcessScope((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                )->getEntity();
62        }
63        #sms notifications for clients with and without appointment if telephone number is given
64        if (
65            $process->scope->hasNotificationEnabled() &&
66            $process->getFirstClient()->hasTelephone()
67        ) {
68            \App::$http
69                ->readPostResult(
70                    '/process/' . $process->getId() . '/' . $process->getAuthKey() . '/delete/notification/',
71                    $process
72                )->getEntity();
73        }
74    }
75}