Completed
Pull Request — master (#293)
by Jason
08:47
created

DonationProduct_Controller::PurchaseForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php
2
3
class DonationProduct extends ProductPage
4
{
5
    /**
6
     * @var string
7
     */
8
    private static $singular_name = 'Donation';
9
10
    /**
11
     * @var string
12
     */
13
    private static $plural_name = 'Donations';
14
15
    /**
16
     * @var array
17
     */
18
    private static $allowed_children = [];
0 ignored issues
show
Unused Code introduced by
The property $allowed_children is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
20
    /**
21
     * @return FieldList
22
     */
23
    public function getCMSFields()
24
    {
25
        $fields = parent::getCMSFields();
26
27
        $fields->removeByName([
28
            'Weight',
29
            'Price',
30
        ]);
31
32
        return $fields;
33
    }
34
}
35
36
class DonationProduct_Controller extends ProductPage_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
37
{
38
    /**
39
     *
40
     */
41
    public function init()
42
    {
43
        parent::init();
44
        Requirements::javascript("framework/thirdparty/jquery/jquery.js");
45
        Requirements::javascript("sheboygan-youth-sailing/javascript/donationProduct.js");
46
    }
47
48
    /**
49
     * @return FoxyStripePurchaseForm
50
     */
51
    public function PurchaseForm()
52
    {
53
        $form = parent::PurchaseForm();
54
55
        $fields = $form->Fields();
56
57
        $fields->insertBefore(CurrencyField::create('price'), 'quantity');
58
59
        $fields->removeByName(array(
60
            'quantity',
61
        ));
62
63
        return $form;
64
    }
65
}