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

ImageClickSpotsExtension::updateCMSFields()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 16
rs 9.8666
1
<?php
2
3
namespace Sunnysideup\ImageClickSpots\Extension;
4
5
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
6
use SilverStripe\Forms\GridField\GridField;
7
use SilverStripe\AssetAdmin\Forms\UploadField;
0 ignored issues
show
Bug introduced by
The type SilverStripe\AssetAdmin\Forms\UploadField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SilverStripe\Assets\Image;
9
use SilverStripe\Forms\FieldList;
10
use SilverStripe\ORM\DataExtension;
11
use Sunnysideup\ImageClickSpots\Model\DataPoint;
12
13
class ImageClickSpotsExtension extends DataExtension
14
{
15
    private static $has_one = [
16
        'DataPointImage' => Image::class,
17
    ];
18
19
    private static $has_many = [
20
        'DataPoints' => DataPoint::class.'.Parent',
21
    ];
22
23
    public function updateCMSFields(FieldList $fields)
24
    {
25
        $fields->addFieldsToTab(
26
            'Root.ImageWithDataPoints',
27
            [
28
                UploadField::create(
29
                    'DataPointImage',
30
                    'Image'
31
                )
32
                    ->setFolderName('data-point-images'),
33
                GridField::create(
34
                    'DataPoints',
35
                    'Data Points',
36
                    $this->owner->DataPoints(),
37
                    GridFieldConfig_RelationEditor::create()
38
                )->setDescription('Please add as many datapoints as needed.'),
39
            ]
40
        );
41
    }
42
}
43