OrderAttribute::ShowInTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace SilverShop\Model;
4
5
use SilverStripe\ORM\DataObject;
6
use SilverStripe\ORM\FieldType\DBCurrency;
7
8
/**
9
 * A single line in an order. This could be an item, or a subtotal line.
10
 *
11
 * @see OrderItem
12
 * @see OrderModifier
13
 *
14
 * @property DBCurrency $CalculatedTotal
15
 * @property int $OrderID
16
 * @method   Order Order()
17
 */
18
class OrderAttribute extends DataObject
19
{
20
    private static $singular_name = 'Attribute';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
21
22
    private static $plural_name = 'Attributes';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
23
24
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
25
        'CalculatedTotal' => 'Currency',
26
    ];
27
28
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
29
        'Order' => Order::class,
30
    ];
31
32
    private static $casting = [
0 ignored issues
show
introduced by
The private property $casting is not used, and could be removed.
Loading history...
33
        'TableTitle' => 'Text',
34
        'CartTitle' => 'Text',
35
    ];
36
37
    private static $table_name = 'SilverShop_OrderAttribute';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
38
39
    public function canCreate($member = null, $context = [])
40
    {
41
        return false;
42
    }
43
44
    public function canDelete($member = null)
45
    {
46
        return false;
47
    }
48
49
    public function isLive()
50
    {
51
        return (!$this->isInDB() || $this->Order()->IsCart());
52
    }
53
54
    /**
55
     * Produces a title for use in templates.
56
     *
57
     * @return string
58
     */
59
    public function getTableTitle()
60
    {
61
        $title = $this->i18n_singular_name();
62
        $this->extend('updateTableTitle', $title);
63
        return $title;
64
    }
65
66
    public function getCartTitle()
67
    {
68
        $title = $this->getTableTitle();
69
        $this->extend('updateCartTitle', $title);
70
        return $title;
71
    }
72
73
    public function ShowInTable()
74
    {
75
        $showInTable = true;
76
        $this->extend('updateShowInTable', $showInTable);
77
        return $showInTable;
78
    }
79
}
80