SiteConfigExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 50
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 32 1
1
<?php
2
/**
3
 * SiteConfigExtension.php
4
 *
5
 * @author Bram de Leeuw
6
 * Date: 09/03/17
7
 */
8
9
namespace Broarm\EventTickets;
10
11
use DataExtension;
12
use FieldList;
13
use HtmlEditorField;
14
use SiteConfig;
15
use TreeDropdownField;
16
use UploadField;
17
18
/**
19
 * Class SiteConfigExtension
20
 *
21
 * @package Broarm\EventTickets
22
 *
23
 * @property TicketScannerExtension|\SiteConfig $owner
24
 * @property string                             SuccessMessage
25
 * @property string                             SuccessMessageMail
26
 *
27
 * @method \Image TicketLogo
28
 * @method \Page TermsPage
29
 */
30
class SiteConfigExtension extends DataExtension
31
{
32
    private static $db = array(
33
        'SuccessMessage' => 'HTMLText',
34
        'SuccessMessageMail' => 'HTMLText'
35
    );
36
37
    private static $has_one = array(
38
        'TicketLogo' => 'Image',
39
        'TermsPage' => 'SiteTree'
40
    );
41
42
    private static $defaults = array(
43
        'SuccessMessage' => "<p>Thanks for your order!<br/>The requested tickets are sent to you by mail.</p>",
44
        'SuccessMessageMail' => "<p>This is your ticket.<br/>You can scan the QR code at the ticket check.</p>"
45
    );
46
47
    public function updateCMSFields(FieldList $fields)
48
    {
49
        $termsPage = new TreeDropdownField('TermsPageID', 'Terms and conditions to mention on checkout', 'SiteTree');
50
51
        $success = new HtmlEditorField('SuccessMessage', 'Success message');
52
        $success->setRows(4);
53
        $success->setDescription(_t(
54
            'SiteConfigExtension.SUCCESS_MESSAGE_HELP',
55
            'This message is used on the success page. The text is overwriteble for a specific event under the "Tickets" tab'
56
        ));
57
58
        $mail = new HtmlEditorField('SuccessMessageMail', 'Mail message');
59
        $mail->setRows(4);
60
        $mail->setDescription(_t(
61
            'SiteConfigExtension.TICKET_MESSAGE_HELP',
62
            'This message is used on ticket. You can reference the therms and agreements here or explain the scan process'
63
        ));
64
65
        $uploadField = UploadField::create('TicketLogo', 'TicketLogo');
66
        $uploadField->setAllowedMaxFileNumber(1);
67
        $uploadField->setFolderName('event-tickets/ticket-logo');
68
        $uploadField->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg'));
69
70
        $fields->addFieldsToTab('Root.Tickets', array(
71
            $termsPage,
72
            $success,
73
            $mail,
74
            $uploadField
75
        ));
76
77
        return $fields;
78
    }
79
}
80