Passed
Push — master ( da5c3a...138f6a )
by Torben
132:09 queued 128:49
created

EventPlausability::addData()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
nc 2
nop 1
dl 0
loc 14
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Form\FormDataProvider;
13
14
use DERHANSEN\SfEventMgt\Service\EventPlausabilityService;
15
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17
18
/**
19
 * Uses EventPlausabilityService to check if event contains unplausible settings.
20
 */
21
class EventPlausability implements FormDataProviderInterface
22
{
23
    public function addData(array $result): array
24
    {
25
        if ($result['tableName'] !== 'tx_sfeventmgt_domain_model_event' || empty($result['databaseRow'])) {
26
            return $result;
27
        }
28
29
        $eventPlausabilityService = GeneralUtility::makeInstance(EventPlausabilityService::class);
30
        $eventPlausabilityService->verifyEventStartAndEnddate(
31
            (int)$result['databaseRow']['startdate'],
32
            (int)$result['databaseRow']['enddate']
33
        );
34
        $eventPlausabilityService->verifyOrganisatorConfiguration($result['databaseRow']);
35
36
        return $result;
37
    }
38
}
39