Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ProcessDelete
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
5
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%
9 / 9
100.00% covered (success)
100.00%
1 / 1
4
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 \Psr\Http\Message\ResponseInterface
23     */
24    #[\Override]
25    public function readResponse(
26        \Psr\Http\Message\RequestInterface $request,
27        \Psr\Http\Message\ResponseInterface $response,
28        array $args
29    ): \Psr\Http\Message\ResponseInterface {
30        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
31        $processId = Validator::value($args['id'])->isNumber()->getValue();
32        $initiator = Validator::param('initiator')->isString()->getValue();
33        $process = \App::$http->readGetResult('/process/' . $processId . '/')->getEntity();
34        $process->status = 'deleted';
35        $workstation->validateProcessScopeAccess((new Helper\ClusterHelper($workstation))->getScopeList(), $process);
36
37        \App::$http->readDeleteResult('/process/' . $process->getId() . '/', ['initiator' => $initiator]);
38        static::writeDeleteMailNotifications($process);
39
40        return \BO\Slim\Render::withHtml(
41            $response,
42            'element/helper/messageHandler.twig',
43            array(
44                'success' => 'process_deleted',
45                'selectedprocess' => $process,
46            )
47        );
48    }
49
50    public static function writeDeleteMailNotifications($process)
51    {
52        #email only for clients with appointment if email address is given
53        if (
54            $process->getFirstClient()->hasEmail() &&
55            $process->isWithAppointment() &&
56            $process->scope->hasEmailFrom()
57        ) {
58            \App::$http
59                ->readPostResult(
60                    '/process/' . $process->getId() . '/' . $process->getAuthKey() . '/delete/mail/',
61                    $process,
62                    ['initiator' => 'admin']
63                )->getEntity();
64        }
65    }
66}