Completed
Pull Request — master (#291)
by Jason
09:04
created

OrderDetail::canDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
class OrderDetail extends DataObject
4
{
5
    /**
6
     * @var string
7
     */
8
    private static $singular_name = 'Order Detail';
9
10
    /**
11
     * @var string
12
     */
13
    private static $plural_name = 'Order Details';
14
15
    /**
16
     * @var string
17
     */
18
    private static $description = '';
19
20
    /**
21
     * @var array
22
     */
23
    private static $db = array(
24
        'Quantity' => 'Int',
25
        'Price' => 'Currency'
26
    );
27
28
    /**
29
     * @var array
30
     */
31
    private static $has_one = array(
32
        'Product' => 'ProductPage',
33
        'Order' => 'Order'
34
    );
35
36
    /**
37
     * @var array
38
     */
39
    private static $many_many = array(
40
        'Options' => 'OptionItem'
41
    );
42
43
    /**
44
     * @var array
45
     */
46
    private static $summary_fields = array(
47
        'Product.Title',
48
        'Quantity',
49
        'Price.Nice'
50
    );
51
52
    /**
53
     * @return FieldList
54
     */
55 1
    public function getCMSFields()
56
    {
57 1
        $fields = parent::getCMSFields();
58
59 1
        if ($this->ID) {
60 1
            $fields->addFieldsToTab('Root.Options', array(
61 1
                GridField::create('Options', 'Product Options', $this->Options(), GridFieldConfig_RecordViewer::create())
0 ignored issues
show
Documentation Bug introduced by
The method Options does not exist on object<OrderDetail>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
62 1
            ));
63 1
        }
64
65 1
        return $fields;
66
    }
67
68
    /**
69
     * @param bool $member
70
     * @return bool|int
71
     */
72 1
    public function canView($member = false)
73
    {
74 1
        return Permission::check('Product_ORDERS');
75
    }
76
77
    /**
78
     * @param null $member
79
     * @return bool
80
     */
81 1
    public function canEdit($member = null)
82
    {
83 1
        return false;
84
    }
85
86
    /**
87
     * @param null $member
88
     * @return bool|int
89
     */
90 1
    public function canDelete($member = null)
91
    {
92 1
        return false;
93
    }
94
95
    /**
96
     * @param null $member
97
     * @return bool
98
     */
99 1
    public function canCreate($member = null)
100
    {
101 1
        return false;
102
    }
103
}
104