Completed
Branch master (003c26)
by Pixelneat
02:56
created

ImageSliderItem::plural_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author    Donatas Navidonskis <[email protected]>
5
 * @since     2017
6
 * @class     ImageSliderItem
7
 *
8
 * @property int PictureID
9
 *
10
 * @method Image Picture
11
 */
12
class ImageSliderItem extends BaseSliderItem {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
14
    /**
15
     * @var array
16
     * @config
17
     */
18
    private static $has_one = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
        'Picture' => 'Image',
20
    ];
21
22
    /**
23
     * @return string
24
     */
25
    public function singular_name() {
26
        return _t('ImageSliderItem.SINGULARNAME', 'Image slider');
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function plural_name() {
33
        return _t('ImageSliderItem.PLURALNAME', 'Image sliders');
34
    }
35
36
    /**
37
     * @return \FieldList
38
     */
39
    public function getCMSFields() {
40
        $fields = parent::getCMSFields();
41
        $fields->removeByName(['Picture']);
42
        $fields->findOrMakeTab('Root.Media', $this->fieldLabel('Media'));
43
44
        $fields->addFieldToTab('Root.Media', $uploadField = UploadField::create('Picture', $this->fieldLabel('Picture')));
45
46
        $uploadField
47
            ->setAllowedMaxFileNumber(1)
48
            ->setAllowedFileCategories('image')
49
            ->setFolderName(
50
                sprintf('%s/Sliders', BaseBlock::config()->upload_directory)
51
            );
52
53
        $this->extend('updateCMSFields', $fields);
54
55
        return $fields;
56
    }
57
}