Passed
Push — 1.0 ( dbac97...74fb09 )
by Morven
04:14
created

LineItemGridField   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A performReadonlyTransformation() 0 10 1
1
<?php
2
3
namespace SilverCommerce\OrdersAdmin\Forms\GridField;
4
5
use SilverStripe\Forms\GridField\GridField;
6
use SilverStripe\Forms\GridField\GridFieldDataColumns;
7
8
/**
9
 * GridField used for order items that allows a proper ReadOnly version
10
 */
11
class LineItemGridField extends GridField
12
{
13
    /**
14
     * Returns a readonly version of this field
15
     * @return GridField
16
     */
17
    public function performReadonlyTransformation()
18
    {
19
        $this->getConfig()
20
            ->removeComponentsByType("GridFieldDeleteAction")
21
            ->removeComponentsByType("GridFieldAddExistingAutocompleter")
22
            ->removeComponentsByType("GridFieldEditableColumns")
23
            ->removeComponentsByType("GridFieldAddNewButton")
24
            ->addComponent(new GridFieldDataColumns());
25
            
26
        return $this;
27
    }
28
}
29