Passed
Pull Request — master (#2)
by Guy
08:17
created

DataPoint::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 16
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Sunnysideup\ImageClickSpots\Model;
4
5
use JonoM\ImageCoord\ImageCoordField;
6
use SilverStripe\ORM\DataObject;
7
8
class DataPoint extends DataObject
9
{
10
    private static $table_name = 'Sunnysideup_clickspots_DataPoint';
11
12
    private static $db = [
13
       'Title' => 'Varchar',
14
       'Description' => 'HTMLText',
15
    ];
16
17
    private static $has_one = [
18
        'Parent' => DataObject::class,
19
    ];
20
21
    public function getCMSFields()
22
    {
23
       $fields = parent::getCMSFields();
24
       $fields->addFieldToTab(
25
           'Root.Main',
26
           ImageCoordField::create(
27
               $name = 'DataPointImageCoordinates',
28
               $xFieldName = 'XCoordinate',
29
               $yFieldName = 'YCoordinate',
30
               $imageURL = $this->Parent()->DataPointImage()->Link(),
0 ignored issues
show
Bug introduced by
The method Parent() does not exist on Sunnysideup\ImageClickSpots\Model\DataPoint. 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

30
               $imageURL = $this->/** @scrutinizer ignore-call */ Parent()->DataPointImage()->Link(),
Loading history...
31
               $width = $this->Parent()->DataPointImage()->getWidth(),
32
               $height = $this->Parent()->DataPointImage()->getHeight(),
33
               $cssGrid = true
34
           )
35
       );
36
       return $fields;
37
    }
38
}
39