Passed
Push — 1.0 ( 024343...5b8585 )
by Morven
10:07
created

SiteConfigExtension::updateCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 19
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace SilverCommerce\ShoppingCart\Extensions;
4
5
use SilverStripe\ORM\DataExtension;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\ToggleCompositeField;
8
use SilverStripe\Forms\CheckboxField;
9
10
/**
11
 * Extension for Site Config that provides extra features
12
 *
13
 * @author ilateral (http://www.ilateral.co.uk)
14
 * @package shoppingcart
15
 */
16
class SiteConfigExtension extends DataExtension
17
{
18
    
19
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
20
        "ShowCartPostageForm" => "Boolean",
21
        "ShowCartDiscountForm" => "Boolean",
22
        'LastEstimateClean' => 'DBDatetime'
23
    ];
24
    
25
    public function updateCMSFields(FieldList $fields)
26
    {
27
        $fields->removeByName("ShowCartPostageForm");
28
        $fields->removeByName("ShowCartDiscountForm");
29
        $fields->removeByName("LastEstimateClean");
30
31
        $fields->addFieldToTab(
32
            "Root.Shop",
33
            ToggleCompositeField::create(
34
                'ShoppingCartSettings',
35
                _t("ShoppingCart.ShoppingCart", "Shopping Cart Settings"),
36
                [
37
                    CheckboxField::create(
38
                        "ShowCartPostageForm",
39
                        $this->owner->fieldLabel("ShowCartPostageForm")
40
                    ),
41
                    CheckboxField::create(
42
                        "ShowCartDiscountForm",
43
                        $this->owner->fieldLabel("ShowCartDiscountForm")
44
                    )
45
                ]
46
            )
47
        );
48
    }
49
}
50