AttributeValue   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 11 1
1
<?php
2
3
namespace SilverShop\Model\Variation;
4
5
use SilverStripe\Forms\FieldList;
6
use SilverStripe\ORM\DataObject;
7
use SilverStripe\ORM\ManyManyList;
8
9
/**
10
 * Product Attribute Value
11
 * The actual values for a type of product attribute.
12
 * eg: red, green, blue... 12, 13, 15
13
 *
14
 * @property string $Value
15
 * @property int $Sort
16
 * @method   AttributeType Type()
17
 * @method   Variation[]|ManyManyList ProductVariation()
18
 */
19
class AttributeValue extends DataObject
20
{
21
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
22
        'Value' => 'Varchar',
23
        'Sort' => 'Int',
24
    ];
25
26
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
27
        'Type' => AttributeType::class,
28
    ];
29
30
    private static $belongs_many_many = [
0 ignored issues
show
introduced by
The private property $belongs_many_many is not used, and could be removed.
Loading history...
31
        'ProductVariation' => Variation::class,
32
    ];
33
34
    private static $summary_fields = [
0 ignored issues
show
introduced by
The private property $summary_fields is not used, and could be removed.
Loading history...
35
        'Value' => 'Value',
36
    ];
37
38
    private static $indexes = [
0 ignored issues
show
introduced by
The private property $indexes is not used, and could be removed.
Loading history...
39
        'LastEdited' => true,
40
        'Sort' => true,
41
    ];
42
43
    private static $table_name = 'SilverShop_AttributeValue';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
44
45
    private static $default_sort = '"TypeID" ASC, "Sort" ASC, "Value" ASC';
0 ignored issues
show
introduced by
The private property $default_sort is not used, and could be removed.
Loading history...
46
47
    private static $singular_name = 'Value';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
48
49
    private static $plural_name = 'Values';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
50
51
    public function getCMSFields()
52
    {
53
        $this->beforeUpdateCMSFields(
54
            function (FieldList $fields) {
55
56
                $fields->removeByName('TypeID');
57
                $fields->removeByName('Sort');
58
            }
59
        );
60
61
        return parent::getCMSFields();
62
    }
63
}
64