Completed
Push — master ( 532720...1aeaec )
by Jason
11s
created

PromoObject   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 50
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 21 1
1
<?php
2
3
namespace Dynamic\Elements\Promos\Model;
4
5
use Dynamic\BaseObject\Model\BaseElementObject;
6
use Dynamic\Elements\Promos\Elements\ElementPromos;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\GridField\GridField;
9
use SilverStripe\Forms\GridField\GridFieldConfig_RecordViewer;
10
11
/**
12
 * Class PromoObject.
13
 */
14
class PromoObject extends BaseElementObject
15
{
16
    /**
17
     * @return string
18
     */
19
    private static $singular_name = 'Promo';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
20
21
    /**
22
     * @return string
23
     */
24
    private static $plural_name = 'Promos';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
25
26
    /**
27
     * @var array
28
     */
29
    private static $belongs_many_many = array(
0 ignored issues
show
introduced by
The private property $belongs_many_many is not used, and could be removed.
Loading history...
30
        'ElementPromos' => ElementPromos::class,
31
    );
32
33
    /**
34
     * @var string
35
     */
36
    private static $table_name = 'PromoObject';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
37
38
    /**
39
     * @return FieldList
40
     *
41
     * @throws \Exception
42
     */
43
    public function getCMSFields()
44
    {
45 1
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
46 1
            $fields->removeByName('ElementPromos');
47
48 1
            $config = GridFieldConfig_RecordViewer::create();
49 1
            $fields->addFieldToTab(
50 1
                'Root.Elements',
51 1
                GridField::create(
52 1
                    'ElementPromos',
53 1
                    'Elements',
54 1
                    $this->ElementPromos(),
0 ignored issues
show
Bug introduced by
The method ElementPromos() does not exist on Dynamic\Elements\Promos\Model\PromoObject. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
                    $this->/** @scrutinizer ignore-call */ 
55
                           ElementPromos(),
Loading history...
55 1
                    $config
56
                )
57
            );
58
59 1
            $fields->dataFieldByName('Image')
60 1
                ->setFolderName('Uploads/Elements/Promos');
61 1
        });
62
63
        return parent::getCMSFields();
64
    }
65
}
66