Passed
Pull Request — master (#198)
by Nic
02:28
created

VideoEmbedSlide::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace Dynamic\FlexSlider\Model;
4
5
use Sheadawson\Linkable\Forms\EmbeddedObjectField;
6
use Sheadawson\Linkable\Models\EmbeddedObject;
7
use SilverStripe\AssetAdmin\Forms\UploadField;
8
use SilverStripe\Assets\File;
9
use SilverStripe\Forms\FieldList;
10
11
/**
12
 * Class VideoEmbedSlide
13
 * @package Dynamic\FlexSlider\Model
14
 */
15
class VideoEmbedSlide extends Slide
16
{
17
    /**
18
     * @var string
19
     */
20
    private static $singular_name = 'Video Embed Slide';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
21
22
    /**
23
     * @var string
24
     */
25
    private static $plural_name = 'Video Embed Slides';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
26
27
    /**
28
     * @var string
29
     */
30
    private static $table_name = 'VideoEmbedSlide';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
31
32
    /**
33
     * @var array
34
     */
35
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
36
        'Video' => EmbeddedObject::class,
37
    ];
38
39
    /**
40
     * @return FieldList
41
     */
42
    public function getCMSFields()
43
    {
44
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
45
            $fields->removeByName(['VideoID']);
46
            $fields->addFieldToTab(
47
                'Root.Main',
48
                EmbeddedObjectField::create('Video', 'Video', $this->Video()),
0 ignored issues
show
Bug introduced by
The method Video() does not exist on Dynamic\FlexSlider\Model\VideoEmbedSlide. 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

48
                EmbeddedObjectField::create('Video', 'Video', $this->/** @scrutinizer ignore-call */ Video()),
Loading history...
49
                'Content'
50
            );
51
        });
52
53
        return parent::getCMSFields();
54
    }
55
}
56