1 | <?php |
||
2 | |||
3 | namespace Dynamic\FoxyStripe\Admin; |
||
4 | |||
5 | use Dynamic\FoxyStripe\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
![]() |
|||
17 | Order::class, |
||
18 | ); |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private static $url_segment = 'orders'; |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private static $menu_title = 'Orders'; |
||
0 ignored issues
–
show
|
|||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | private static $menu_priority = 4; |
||
0 ignored issues
–
show
|
|||
34 | |||
35 | /** |
||
36 | * @param null $id |
||
0 ignored issues
–
show
|
|||
37 | * @param null $fields |
||
0 ignored issues
–
show
|
|||
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); |
||
0 ignored issues
–
show
Are you sure the assignment to
$gridField is correct as $form->Fields()->fieldByName($gridFieldName) targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
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 |