OrderAdmin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEditForm() 0 12 1
1
<?php
2
3
namespace Dynamic\Foxy\Orders\Admin;
4
5
use Dynamic\Foxy\Orders\Model\Order;
6
use SilverStripe\Admin\ModelAdmin;
7
use SilverStripe\Forms\GridField\GridField;
8
use SilverStripe\Forms\GridField\GridFieldConfig;
9
use SilverStripe\Forms\GridField\GridFieldConfig_RecordViewer;
10
use SilverStripe\Forms\GridField\GridFieldEditButton;
11
12
/**
13
 * Class OrderAdmin
14
 * @package Dynamic\Foxy\Orders\Admin
15
 */
16
class OrderAdmin extends ModelAdmin
17
{
18
    /**
19
     * @var array
20
     */
21
    private static $managed_models = [
0 ignored issues
show
introduced by
The private property $managed_models is not used, and could be removed.
Loading history...
22
        Order::class,
23
    ];
24
25
    /**
26
     * @var string
27
     */
28
    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...
29
30
    /**
31
     * @var string
32
     */
33
    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...
34
35
    /**
36
     * @var int
37
     */
38
    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...
39
40
    /**
41
     * @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...
42
     * @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...
43
     *
44
     * @return \SilverStripe\Forms\Form
45
     */
46
    public function getEditForm($id = null, $fields = null)
47
    {
48
        $form = parent::getEditForm($id, $fields);
49
50
        $gridFieldName = $this->sanitiseClassName($this->modelClass);
51
        /** @var GridField $gridField */
52
        $gridField = $form->Fields()->fieldByName($gridFieldName);
53
54
        /** @var $config GridFieldConfig_RecordViewer */
55
        $gridField->setConfig($config = GridFieldConfig_RecordViewer::create());
56
57
        return $form;
58
    }
59
}
60