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