Completed
Push — master ( fbfc98...86fc64 )
by Jason
9s
created

PhotoGalleryBlockImage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 110
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 14 1
A canCreate() 0 4 1
A canView() 0 4 1
A canEdit() 0 4 1
A canDelete() 0 4 1
1
<?php
2
3
class PhotoGalleryBlockImage extends DataObject
4
{
5
    /**
6
     * @var string
7
     */
8
    private static $singular_name = 'Gallery Image';
9
10
    /**
11
     * @var string
12
     */
13
    private static $plural_name = 'Gallery Images';
14
15
    /**
16
     * @var array
17
     */
18
    private static $db = array(
19
        'Title' => 'Varchar(255)',
20
        'Content' => 'HTMLText',
21
        'SortOrder' => 'Int',
22
    );
23
24
    /**
25
     * @var array
26
     */
27
    private static $has_one = array(
28
        'PhotoGallery' => 'PhotoGalleryBlock',
29
        'Image' => 'Image',
30
    );
31
32
    /**
33
     * @var array
34
     */
35
    private static $summary_fields = array(
36
        'Image.CMSThumbnail' => 'Image',
37
        'Title' => 'Title',
38
    );
39
40
    /**
41
     * @var array
42
     */
43
    private static $searchable_fields = array(
44
        'Title',
45
        'Content',
46
    );
47
48
    /**
49
     * @var array
50
     */
51
    private static $extensions = [
52
        'VersionedDataObject'
53
    ];
54
55
    /**
56
     * @return FieldList
57
     */
58 1
    public function getCMSFields()
59
    {
60 1
        $fields = parent::getCMSFields();
61
62 1
        $fields->removeByName(array(
63 1
            'SortOrder',
64 1
            'PhotoGalleryID',
65 1
        ));
66
67 1
        $image = $fields->dataFieldByName('Image')->setFolderName('Uploads/Blocks/PhotoGallery/');
68 1
        $fields->insertBefore($image, 'Content');
0 ignored issues
show
Documentation introduced by
'Content' is of type string, but the function expects a object<FormField>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69
70 1
        return $fields;
71
    }
72
73
    /**
74
     * @param null $member
75
     *
76
     * @return bool
77
     */
78 1
    public function canCreate($member = null)
79
    {
80 1
        return true;
81
    }
82
83
    /**
84
     * @param null $member
85
     *
86
     * @return bool
87
     */
88 1
    public function canView($member = null)
89
    {
90 1
        return true;
91
    }
92
93
    /**
94
     * @param null $member
95
     *
96
     * @return bool
97
     */
98 1
    public function canEdit($member = null)
99
    {
100 1
        return true;
101
    }
102
103
    /**
104
     * @param null $member
105
     *
106
     * @return bool
107
     */
108 1
    public function canDelete($member = null)
109
    {
110 1
        return true;
111
    }
112
}
113