Completed
Pull Request — master (#21)
by
unknown
02:00
created

DMSDocumentCartSubmission::getCMSFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
class DMSDocumentCartSubmission extends DataObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private static $db = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $db 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...
6
        'ReceiverName'            => 'Varchar(100)',
7
        'ReceiverPhone'           => 'Varchar(20)',
8
        'ReceiverEmail'           => 'Varchar(254)',
9
        'DeliveryAddressLine1'    => 'Varchar(200)',
10
        'DeliveryAddressLine2'    => 'Varchar(200)',
11
        'DeliveryAddressCountry'  => 'Varchar(50)',
12
        'DeliveryAddressPostCode' => 'Varchar(20)',
13
    );
14
15
    private static $has_many = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $has_many 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...
16
        'Items' => 'DMSDocumentCartSubmissionItem',
17
    );
18
19
    private static $summary_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $summary_fields 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...
20
        'ReceiverName' => 'Receiver Name',
21
        'ReceiverPhone' => 'Receiver Phone',
22
        'ReceiverEmail' => 'Receiver Email',
23
        'Items.Count' => 'No. Items'
24
    );
25
26
    private static $singular_name = 'Cart Submission';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $singular_name 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...
27
    private static $plural_name = 'Cart Submissions';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $plural_name 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...
28
29
    /**
30
     * Removing the add and existing GridField components to ensure that the model admin for submissions doesn't
31
     * let you add new records
32
     *
33
     * @return FieldList
34
     */
35
    public function getCMSFields()
36
    {
37
        $fields = parent::getCMSFields();
38
39
        $gridFieldConfig = $fields->fieldByName('Root.Items.Items')->getConfig();
40
41
        foreach (array('GridFieldAddExistingAutocompleter', 'GridFieldAddNewButton') as $component) {
42
            $gridFieldConfig->removeComponentsByType($component);
43
        }
44
45
        return $fields;
46
    }
47
}
48