Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
96.75% covered (success)
96.75%
268 / 277
88.89% covered (warning)
88.89%
24 / 27
CRAP
0.00% covered (danger)
0.00%
0 / 1
Scope
96.75% covered (success)
96.75%
268 / 277
88.89% covered (warning)
88.89%
24 / 27
48
0.00% covered (danger)
0.00%
0 / 1
 getQueryLastWaitingNumber
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQueryLastDisplayNumber
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getQueryGivenNumbersInContingent
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQuerySimpleClusterMatch
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQuerySimpleDepartmentMatch
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQueryDepartmentIdByScopeId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getQueryClusterIdsByScopeId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getQueryReadImageData
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQueryWriteImageData
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQueryDeleteImage
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addJoin
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
2.01
 addRequiredJoins
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
1 / 1
5
 getEntityMapping
100.00% covered (success)
100.00%
79 / 79
100.00% covered (success)
100.00%
1 / 1
5
 addConditionScopeId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addConditionScopeIds
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 addConditionWithAdminEmail
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addSelectWorkstationCount
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 addConditionProviderId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addConditionDepartmentId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addConditionClusterId
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 reverseEntityMapping
100.00% covered (success)
100.00%
70 / 70
100.00% covered (success)
100.00%
1 / 1
7
 setEmergencyEntityMapping
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 setGhostWorkstationCountEntityMapping
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 postProcess
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 convertTimestamps
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
3
 setDefaultValues
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
2
 setIfEmpty
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace BO\Zmsdb\Query;
4
5class Scope extends Base implements MappingInterface
6{
7    /**
8     * @var String TABLE mysql table reference
9     */
10    const TABLE = 'standort';
11
12    const QUERY_BY_DEPARTMENTID = 'SELECT
13            scope.`StandortID` AS id
14        FROM `standort` scope
15        WHERE
16            scope.`BehoerdenID` = :department_id
17    ';
18
19    public function getQueryLastWaitingNumber()
20    {
21        return '
22            SELECT letztewartenr
23            FROM `standort` scope
24            WHERE scope.`StandortID` = :scope_id LIMIT 1 FOR UPDATE';
25    }
26
27    public function getQueryLastDisplayNumber()
28    {
29        return '
30            SELECT last_display_number
31            FROM `standort` scope
32            WHERE scope.`StandortID` = :scope_id LIMIT 1 FOR UPDATE';
33    }
34
35    public function getQueryGivenNumbersInContingent()
36    {
37        return '
38            SELECT *
39            FROM `standort` scope
40            WHERE
41                scope.`StandortID` = :scope_id AND
42                IF(
43                    scope.`wartenummernkontingent` > 0,
44                    IF(
45                        isNull(scope.`vergebenewartenummern`), 
46                        0, 
47                        scope.`vergebenewartenummern`
48                    ) < scope.`wartenummernkontingent`,
49                    scope.`StandortID`
50                )
51        ';
52    }
53
54    public function getQuerySimpleClusterMatch()
55    {
56        return '
57            SELECT standortID AS id
58            FROM `clusterzuordnung`
59            WHERE
60                clusterID = ?
61        ';
62    }
63
64    public function getQuerySimpleDepartmentMatch()
65    {
66        return '
67            SELECT s.StandortID AS id, p.name AS contact__name
68            FROM `standort` AS s
69            LEFT JOIN `provider` AS p ON s.InfoDienstleisterID = p.id
70                AND p.source = s.source
71            WHERE
72                s.BehoerdenID = ?
73        ';
74    }
75
76    public function getQueryDepartmentIdByScopeId()
77    {
78        return 'SELECT BehoerdenID FROM standort WHERE StandortID = ?';
79    }
80
81    public function getQueryClusterIdsByScopeId()
82    {
83        return 'SELECT clusterID FROM clusterzuordnung WHERE standortID = ?';
84    }
85
86    public function getQueryReadImageData()
87    {
88        return '
89            SELECT `imagecontent`, `imagename`
90            FROM `imagedata`
91            WHERE
92                `imagename` LIKE :imagename
93        ';
94    }
95
96    public function getQueryWriteImageData()
97    {
98        return '
99            REPLACE INTO `imagedata`
100            SET
101                imagename=:imagename,
102                imagecontent=:imagedata
103        ';
104    }
105
106    public function getQueryDeleteImage()
107    {
108        return '
109            DELETE FROM `imagedata`
110            WHERE
111                `imagename` LIKE :imagename
112        ';
113    }
114
115    public function addJoin()
116    {
117        if ($this->shouldLoadEntity('provider')) {
118            $this->leftJoin(
119                new Alias(Provider::getTablename(), 'provider'),
120                self::expression('scope.InfoDienstleisterID = provider.id && scope.source = provider.source')
121            );
122            $providerQuery = new Provider($this, $this->getPrefixed('provider__'));
123            return [$providerQuery];
124        }
125
126        return [];
127    }
128
129    protected function addRequiredJoins()
130    {
131
132        if ($this->shouldLoadEntity('scopedepartment')) {
133            $this->leftJoin(
134                new Alias(Department::TABLE, 'scopedepartment'),
135                'scope.BehoerdenID',
136                '=',
137                'scopedepartment.BehoerdenID'
138            );
139        }
140
141        if ($this->shouldLoadEntity('scopemail') && $this->shouldLoadEntity('scopedepartment')) {
142            $this->leftJoin(
143                new Alias('email', 'scopemail'),
144                'scopedepartment.BehoerdenID',
145                '=',
146                'scopemail.BehoerdenID'
147            );
148        }
149
150        if ($this->shouldLoadEntity('scopeprovider')) {
151            $this->leftJoin(
152                new Alias(Provider::getTablename(), 'scopeprovider'),
153                self::expression('scope.InfoDienstleisterID = scopeprovider.id && scope.source = scopeprovider.source')
154            );
155        }
156    }
157
158    //Todo: now() Parameter to enable query cache
159    public function getEntityMapping()
160    {
161        return array_filter([
162            'hint' => 'scope.Hinweis',
163            'id' => 'scope.StandortID',
164            'contact__name' => $this->shouldLoadEntity('scopeprovider') ? 'scopeprovider.name' : '',
165            'contact__street' => 'scope.Adresse',
166            'contact__email' => 'scope.emailstandortadmin',
167            'contact__country' => self::expression('"Germany"'),
168            'lastChange' => 'scope.updateTimestamp',
169            'preferences__appointment__deallocationDuration' => 'scope.loeschdauer',
170            'preferences__appointment__infoForAppointment' => 'scope.info_for_appointment',
171            'preferences__appointment__infoForAllAppointments' => 'scope.info_for_all_appointments',
172            'preferences__appointment__endInDaysDefault' => 'scope.Termine_bis',
173            'preferences__appointment__multipleSlotsEnabled' => 'scope.mehrfachtermine',
174            'preferences__appointment__reservationDuration' => 'scope.reservierungsdauer',
175            'preferences__appointment__activationDuration' => 'scope.aktivierungsdauer',
176            'preferences__appointment__startInDaysDefault' => 'scope.Termine_ab',
177            'preferences__client__amendmentActivated' => 'scope.anmerkungPflichtfeld',
178            'preferences__client__amendmentLabel' => 'scope.anmerkungLabel',
179            'preferences__client__emailFrom' => $this->shouldLoadEntity('scopemail')
180                ? 'scopemail.absenderadresse'
181                : '',
182            'preferences__client__emailRequired' => 'scope.emailPflichtfeld',
183            'preferences__client__emailConfirmationActivated' => 'scope.email_confirmation_activated',
184            'preferences__client__telephoneActivated' => 'scope.telefonaktiviert',
185            'preferences__client__telephoneRequired' => 'scope.telefonPflichtfeld',
186            'preferences__client__appointmentsPerMail' => 'scope.appointments_per_mail',
187            'preferences__client__slotsPerAppointment' => 'scope.slots_per_appointment',
188            'preferences__client__whitelistedMails' => 'scope.whitelisted_mails',
189            'preferences__client__customTextfieldActivated' => 'scope.custom_text_field_active',
190            'preferences__client__customTextfieldRequired' => 'scope.custom_text_field_required',
191            'preferences__client__customTextfieldLabel' => 'scope.custom_text_field_label',
192            'preferences__client__customTextfield2Activated' => 'scope.custom_text_field2_active',
193            'preferences__client__customTextfield2Required' => 'scope.custom_text_field2_required',
194            'preferences__client__customTextfield2Label' => 'scope.custom_text_field2_label',
195            'preferences__client__captchaActivatedRequired' => 'scope.captcha_activated_required',
196            'preferences__client__adminMailOnAppointment' => 'scope.admin_mail_on_appointment',
197            'preferences__client__adminMailOnDeleted' => 'scope.admin_mail_on_deleted',
198            'preferences__client__adminMailOnUpdated' => 'scope.admin_mail_on_updated',
199            'preferences__client__adminMailOnMailSent' => 'scope.admin_mail_on_mail_sent',
200            'preferences__queue__callCountMax' => 'scope.anzahlwiederaufruf',
201            'preferences__queue__callDisplayText' => 'scope.aufrufanzeigetext',
202            'preferences__queue__firstNumber' => 'scope.startwartenr',
203            'preferences__queue__lastNumber' => 'scope.endwartenr',
204            'preferences__queue__maxNumberContingent' => 'scope.wartenummernkontingent',
205            'preferences__queue__displayNumberPrefix' => 'scope.display_number_prefix',
206            'preferences__queue__processingTimeAverage' => self::expression(
207                'FLOOR(TIME_TO_SEC(`scope`.`Bearbeitungszeit`) / 60)'
208            ),
209            'preferences__queue__statisticsEnabled' => self::expression('NOT `scope`.`ohnestatistik`'),
210            'preferences__survey__emailContent' => 'scope.kundenbef_emailtext',
211            'preferences__survey__enabled' => 'scope.kundenbefragung',
212            'preferences__survey__label' => 'scope.kundenbef_label',
213            'preferences__ticketprinter__buttonName' => self::expression(
214                'IF(`scope`.`standortinfozeile`!="", `scope`.`standortinfozeile`, `scope`.`Bezeichnung`)'
215            ),
216            'preferences__ticketprinter__deactivatedText' => 'scope.wartenrhinweis',
217            'preferences__workstation__emergencyEnabled' => 'scope.notruffunktion',
218            'preferences__workstation__emergencyRefreshInterval' => self::expression(
219                '(SELECT `value` FROM config WHERE `name`="emergency__refreshInterval")'
220            ),
221            'shortName' => 'scope.standortkuerzel',
222            'status__emergency__acceptedByWorkstation' => 'scope.notrufantwort',
223            'status__emergency__activated' => 'scope.notrufausgeloest',
224            'status__emergency__calledByWorkstation' => 'scope.notrufinitiierung',
225            'status__queue__ghostWorkstationCount' => 'scope.virtuellesachbearbeiterzahl',
226            'status__queue__givenNumberCount' => 'scope.vergebenewartenummern',
227            'status__queue__lastGivenNumber' => 'scope.letztewartenr',
228            'status__queue__lastDisplayNumber' => 'scope.last_display_number',
229            'status__queue__maxDisplayNumber' => 'scope.max_display_number',
230            'status__queue__lastGivenNumberTimestamp' => 'scope.wartenrdatum',
231            'status__ticketprinter__deactivated' => 'scope.wartenrsperre',
232            'provider__id' => $this->shouldLoadEntity('scopeprovider') ? self::expression(
233                'IF(`scopeprovider`.`id`!="", `scopeprovider`.`id`, `scope`.`InfoDienstleisterID`)'
234            ) : '',
235            'provider__source' => $this->shouldLoadEntity('scopeprovider') ? self::expression(
236                'IF(`scopeprovider`.`source`!="", `scopeprovider`.`source`, `scope`.`source`)'
237            ) : '',
238            'source' => 'scope.source'
239        ], 'strlen');
240    }
241
242    public function addConditionScopeId($scopeId)
243    {
244        $this->query->where('scope.StandortID', '=', $scopeId);
245        return $this;
246    }
247
248    public function addConditionScopeIds(array $scopeIds)
249    {
250        $scopeIds = array_values(array_unique(array_map('intval', $scopeIds)));
251        if (!$scopeIds) {
252            $this->query->where(self::expression('1'), '=', 0);
253            return $this;
254        }
255
256        $this->query->whereIn('scope.StandortID', $scopeIds);
257        return $this;
258    }
259
260    public function addConditionWithAdminEmail()
261    {
262        $this->query->where('scope.emailstandortadmin', '!=', '');
263        return $this;
264    }
265
266    public function addSelectWorkstationCount($dateTime)
267    {
268        $this->query->select(
269            ['status__queue__workstationCount' => self::expression('
270                IF(
271                    `scope`.`virtuellesachbearbeiterzahl` > -1,
272                    `scope`.`virtuellesachbearbeiterzahl`,
273                    (
274                        SELECT COUNT(*)
275                        FROM nutzer
276                        WHERE nutzer.StandortID = scope.StandortID
277                        AND nutzer.Datum = "' . $dateTime->format('Y-m-d') . '"
278                        AND nutzer.Arbeitsplatznr <> 0
279                    )
280                )
281            ')
282            ]
283        );
284    }
285
286    public function addConditionProviderId($providerId)
287    {
288        $this->query->where('scope.InfoDienstleisterID', '=', $providerId);
289        return $this;
290    }
291
292    public function addConditionDepartmentId($departmentId)
293    {
294        $this->query->where('scope.BehoerdenID', '=', $departmentId);
295        return $this;
296    }
297
298    public function addConditionClusterId($clusterId)
299    {
300        $this->leftJoin(
301            new Alias('clusterzuordnung', 'cluster_scope'),
302            'scope.StandortID',
303            '=',
304            'cluster_scope.standortID'
305        );
306        $this->query->where('cluster_scope.clusterID', '=', $clusterId);
307        return $this;
308    }
309
310    public function reverseEntityMapping(\BO\Zmsentities\Scope $entity, $parentId = null)
311    {
312        $data = array();
313        if ($parentId) {
314            $data['BehoerdenID'] = $parentId;
315        }
316        $data['InfoDienstleisterID'] = $entity->getProviderId();
317        $data['emailstandortadmin'] = $entity->getContactEMail();
318        $data['standortinfozeile'] = $entity->getScopeInfo();
319        $data['Hinweis'] = $entity->getScopeHint();
320        $data['Bezeichnung'] = $entity->getName();
321        $data['standortkuerzel'] = $entity->shortName;
322        $data['Adresse'] = (isset($entity->contact['street'])) ? $entity->contact['street'] : '';
323        $data['loeschdauer'] = $entity->getPreference('appointment', 'deallocationDuration');
324        $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment');
325        $data['info_for_all_appointments'] = $entity->getPreference('appointment', 'infoForAllAppointments');
326        $data['Termine_bis'] = $entity->getPreference('appointment', 'endInDaysDefault');
327        $data['Termine_ab'] = $entity->getPreference('appointment', 'startInDaysDefault');
328        $data['mehrfachtermine'] = $entity->getPreference('appointment', 'multipleSlotsEnabled', true);
329        $data['reservierungsdauer'] = $entity->getPreference('appointment', 'reservationDuration');
330        $data['aktivierungsdauer'] = $entity->getPreference('appointment', 'activationDuration');
331        $data['anmerkungPflichtfeld'] = $entity->getPreference('client', 'amendmentActivated', true);
332        $data['anmerkungLabel'] = $entity->getPreference('client', 'amendmentLabel');
333        $data['emailPflichtfeld'] = $entity->getPreference('client', 'emailRequired', true);
334        $data['email_confirmation_activated'] = $entity->getPreference('client', 'emailConfirmationActivated', true);
335        $data['telefonaktiviert'] = $entity->getPreference('client', 'telephoneActivated', true);
336        $data['telefonPflichtfeld'] = $entity->getPreference('client', 'telephoneRequired', true);
337        $data['custom_text_field_active'] = $entity->getPreference('client', 'customTextfieldActivated', true);
338        $data['custom_text_field_required'] = $entity->getPreference('client', 'customTextfieldRequired', true);
339        $data['custom_text_field_label'] = $entity->getPreference('client', 'customTextfieldLabel');
340        $data['custom_text_field2_active'] = $entity->getPreference('client', 'customTextfield2Activated', true);
341        $data['custom_text_field2_required'] = $entity->getPreference('client', 'customTextfield2Required', true);
342        $data['custom_text_field2_label'] = $entity->getPreference('client', 'customTextfield2Label');
343        $data['captcha_activated_required'] = $entity->getPreference('client', 'captchaActivatedRequired');
344        $data['appointments_per_mail'] = (int) $entity->getPreference('client', 'appointmentsPerMail');
345        $data['slots_per_appointment'] = (int) $entity->getPreference('client', 'slotsPerAppointment');
346        $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment');
347        $data['whitelisted_mails'] = $entity->getPreference('client', 'whitelistedMails');
348        $data['admin_mail_on_appointment'] = $entity->getPreference('client', 'adminMailOnAppointment', true);
349        $data['admin_mail_on_deleted'] = $entity->getPreference('client', 'adminMailOnDeleted');
350        $data['admin_mail_on_updated'] = $entity->getPreference('client', 'adminMailOnUpdated', true);
351        $data['admin_mail_on_mail_sent'] = $entity->getPreference('client', 'adminMailOnMailSent', true);
352        $data['anzahlwiederaufruf'] = $entity->getPreference('queue', 'callCountMax');
353        $data['aufrufanzeigetext'] = $entity->getPreference('queue', 'callDisplayText', false, '');
354        $data['startwartenr'] = $entity->getPreference('queue', 'firstNumber');
355        $data['endwartenr'] = $entity->getPreference('queue', 'lastNumber');
356        $data['wartenummernkontingent'] = $entity->getPreference('queue', 'maxNumberContingent');
357        $data['display_number_prefix'] = $entity->getPreference('queue', 'displayNumberPrefix')
358            ? strtoupper($entity->getPreference('queue', 'displayNumberPrefix'))
359            : '';
360        $data['Bearbeitungszeit'] = gmdate("H:i", $entity->getPreference('queue', 'processingTimeAverage') * 60);
361        $data['ohnestatistik'] = (0 == $entity->getPreference('queue', 'statisticsEnabled', true)) ? 1 : 0;
362        $data['kundenbef_emailtext'] = $entity->getPreference('survey', 'emailContent');
363        $data['kundenbefragung'] = $entity->getPreference('survey', 'enabled', true);
364        $data['kundenbef_label'] = $entity->getPreference('survey', 'label');
365        $data['wartenrhinweis'] = $entity->getPreference('ticketprinter', 'deactivatedText', false, '');
366        $data['notruffunktion'] = $entity->getPreference('workstation', 'emergencyEnabled', true);
367        $data['notrufantwort'] = $entity->getStatus('emergency', 'acceptedByWorkstation');
368        $data['notrufausgeloest'] = $entity->getStatus('emergency', 'activated');
369        $data['notrufinitiierung'] = $entity->getStatus('emergency', 'calledByWorkstation');
370        $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount');
371        $data['vergebenewartenummern'] = $entity->getStatus('queue', 'givenNumberCount');
372        $data['letztewartenr'] = $entity->getStatus('queue', 'lastGivenNumber');
373        $data['last_display_number'] = $entity->getStatus('queue', 'lastDisplayNumber');
374        $data['max_display_number'] = $entity->getStatus('queue', 'maxDisplayNumber');
375        $lastGivenTimestamp = $entity->getStatus('queue', 'lastGivenNumberTimestamp');
376        $data['wartenrdatum'] = ($lastGivenTimestamp) ? date('Y-m-d', $lastGivenTimestamp) : null;
377        $data['wartenrsperre'] = $entity->getStatus('ticketprinter', 'deactivated');
378        $data['source'] = $entity->getProvider()->source;
379
380        $data = array_filter($data, function ($value) {
381            return ($value !== null && $value !== false);
382        });
383        return $data;
384    }
385
386    public function setEmergencyEntityMapping(\BO\Zmsentities\Scope $entity)
387    {
388        $data['notrufantwort'] = ($entity->toProperty()->status->emergency->acceptedByWorkstation->get(-1));
389        $data['notrufausgeloest'] = intval($entity->toProperty()->status->emergency->activated->get(0));
390        $data['notrufinitiierung'] = ($entity->toProperty()->status->emergency->calledByWorkstation->get(-1));
391        return $data;
392    }
393
394    public function setGhostWorkstationCountEntityMapping(\BO\Zmsentities\Scope $entity, \DateTimeInterface $dateTime)
395    {
396        $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount');
397        $data['datumvirtuellesachbearbeiterzahl'] = $dateTime->format('Y-m-d');
398        return $data;
399    }
400
401    public function postProcess($data)
402    {
403        $data = $this->convertTimestamps($data);
404        $data = $this->setDefaultValues($data);
405        return $data;
406    }
407
408
409    private function convertTimestamps($data)
410    {
411        $lastGivenNumberTimestampKey = $this->getPrefixed("status__queue__lastGivenNumberTimestamp");
412        $lastGivenNumberTimestamp = $data[$lastGivenNumberTimestampKey] ?? null;
413        $data[$lastGivenNumberTimestampKey] = $lastGivenNumberTimestamp !== null ? strtotime($lastGivenNumberTimestamp) : null;
414
415        $lastChangeKey = $this->getPrefixed("lastChange");
416        $lastChange = $data[$lastChangeKey] ?? null;
417        if ($lastChange !== null) {
418            $data[$lastChangeKey] = (new \DateTime($lastChange . \BO\Zmsdb\Connection\Select::$connectionTimezone))
419                ->getTimestamp();
420        } else {
421            $data[$lastChangeKey] = null;
422        }
423
424        return $data;
425    }
426
427    private function setDefaultValues($data)
428    {
429        if ($this->shouldLoadEntity('scopemail')) {
430            $this->setIfEmpty($data, 'preferences__client__emailFrom', [
431                'preferences__client__emailRequired' => 0
432            ]);
433        }
434
435        $this->setIfEmpty($data, 'preferences__client__telephoneActivated', [
436            'preferences__client__telephoneRequired' => 0
437        ]);
438
439        $this->setIfEmpty($data, 'preferences__client__emailConfirmationActivated', [
440            'preferences__client__emailConfirmationActivated' => 0
441        ]);
442
443        $this->setIfEmpty($data, 'contact__email', [
444            'preferences__client__adminMailOnAppointment' => 0,
445            'preferences__client__adminMailOnDeleted' => 0,
446            'preferences__client__adminMailOnUpdated' => 0,
447            'preferences__client__adminMailOnMailSent' => 0,
448        ]);
449
450        $this->setIfEmpty($data, 'preferences__client__customTextfieldActivated', [
451            'preferences__client__customTextfieldRequired' => 0
452        ]);
453
454        $this->setIfEmpty($data, 'preferences__client__customTextfield2Activated', [
455            'preferences__client__customTextfield2Required' => 0
456        ]);
457
458        $this->setIfEmpty($data, 'preferences__client__appointmentsPerMail', [
459            'preferences__client__appointmentsPerMail' => null
460        ]);
461
462        $this->setIfEmpty($data, 'preferences__client__slotsPerAppointment', [
463            'preferences__client__slotsPerAppointment' => null
464        ]);
465
466        $this->setIfEmpty($data, 'preferences__client__whitelistedMails', [
467            'preferences__client__whitelistedMails' => null
468        ]);
469
470        return $data;
471    }
472
473    private function setIfEmpty(&$data, $checkKey, array $setKeys)
474    {
475        if (!$data[$this->getPrefixed($checkKey)]) {
476            foreach ($setKeys as $key => $value) {
477                $data[$this->getPrefixed($key)] = $value;
478            }
479        }
480    }
481}