Issues (236)

src/Admin/OrderAdmin.php (7 issues)

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
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
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
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
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);
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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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