Passed
Push — master ( ecb44a...dbb25a )
by Jason
03:40
created

OrderAdmin::getEditForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 16
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\Foxy\Admin;
4
5
use Dynamic\Foxy\Model\Order;
6
use SilverStripe\Admin\ModelAdmin;
7
use SilverStripe\Forms\GridField\GridField;
8
use SilverStripe\Forms\GridField\GridFieldConfig;
9
use SilverStripe\Forms\GridField\GridFieldEditButton;
10
11
class OrderAdmin extends ModelAdmin
12
{
13
    /**
14
     * @var array
15
     */
16
    private static $managed_models = array(
0 ignored issues
show
introduced by
The private property $managed_models is not used, and could be removed.
Loading history...
17
        Order::class,
18
    );
19
20
    /**
21
     * @var string
22
     */
23
    private static $url_segment = 'orders';
0 ignored issues
show
introduced by
The private property $url_segment is not used, and could be removed.
Loading history...
24
25
    /**
26
     * @var string
27
     */
28
    private static $menu_title = 'Orders';
0 ignored issues
show
introduced by
The private property $menu_title is not used, and could be removed.
Loading history...
29
30
    /**
31
     * @var int
32
     */
33
    private static $menu_priority = 4;
0 ignored issues
show
introduced by
The private property $menu_priority is not used, and could be removed.
Loading history...
34
35
    /**
36
     * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
37
     * @param null $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
38
     *
39
     * @return \SilverStripe\Forms\Form
40
     */
41
    public function getEditForm($id = null, $fields = null)
42
    {
43
        $form = parent::getEditForm($id, $fields);
44
45
        $gridFieldName = $this->sanitiseClassName($this->modelClass);
46
        /** @var GridField $gridField */
47
        $gridField = $form->Fields()->fieldByName($gridFieldName);
48
49
        // GridField configuration
50
        /** @var GridFieldConfig $config */
51
        $config = $gridField->getConfig();
52
53
        // remove edit icon
54
        $config->removeComponentsByType(GridFieldEditButton::class);
55
56
        return $form;
57
    }
58
}
59