LocatorExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 27
c 2
b 0
f 0
dl 0
loc 49
ccs 16
cts 16
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 17 1
1
<?php
2
3
namespace Dynamic\Locator\React\Extensions;
4
5
use SilverStripe\AssetAdmin\Forms\UploadField;
6
use SilverStripe\Assets\Image;
7
use SilverStripe\Forms\CheckboxField;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\Forms\NumericField;
10
use SilverStripe\Forms\TextField;
11
use SilverStripe\ORM\DataExtension;
12
13
/**
14
 * Class LocatorExtension
15
 * @package Dynamic\Locator\React\Extensions
16
 *
17
 * @property float DefaultLat
18
 * @property float DefaultLng
19
 * @property boolean Clusters
20
 * @property boolean Autocomplete
21
 *
22
 * @property int SearchMarkerImageID
23
 * @method Image SearchMarkerImage()
24
 *
25
 * @property int DefaultMarkerImageID
26
 * @method Image DefaultMarkerImage()
27
 */
28
class LocatorExtension extends DataExtension
29
{
30
31
    /**
32
     * @var array
33
     */
34
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
35
        'DefaultLat' => 'Decimal(10,7)',
36
        'DefaultLng' => 'Decimal(10,7)',
37
        'Clusters' => 'Boolean',
38
        'Autocomplete' => 'Boolean',
39
    ];
40
41
    /**
42
     * @var array
43
     */
44
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
45
        'DefaultMarkerImage' => Image::class,
46
        'SearchMarkerImage' => Image::class,
47
    ];
48
49
    /**
50
     * @var array
51
     */
52
    private static $owns = [
0 ignored issues
show
introduced by
The private property $owns is not used, and could be removed.
Loading history...
53
        'DefaultMarkerImage',
54
        'SearchMarkerImage',
55
    ];
56
57
    /**
58
     * @param FieldList $fields
59
     */
60 1
    public function updateCMSFields(FieldList $fields)
61
    {
62 1
        $fields->addFieldsToTab('Root.Settings', [
63 1
            NumericField::create('DefaultLat')
64 1
                ->setTitle('Default Latitude')
65 1
                ->setScale(7),
66 1
            NumericField::create('DefaultLng')
67 1
                ->setTitle('Default Longitude')
68 1
                ->setScale(7),
69 1
            UploadField::create('DefaultMarkerImage')
70 1
                ->setRightTitle('The default image to use for markers.'),
71 1
            UploadField::create('SearchMarkerImage')
72 1
                ->setRightTitle('The image the search marker will have.'),
73 1
            CheckboxField::create('Clusters')
74 1
                ->setRightTitle('Cluster the markers when zoomed out.'),
75 1
            CheckboxField::create('Autocomplete')
76 1
                ->setRightTitle('Address field will suggest locations')
77
        ]);
78
    }
79
}
80