Passed
Pull Request — master (#144)
by Robbie
01:58
created

ElementContent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 8 1
A getType() 0 3 1
A getSummary() 0 3 1
1
<?php
2
3
namespace DNADesign\Elemental\Models;
4
5
use SilverStripe\Forms\HTMLEditor\HtmlEditorField;
6
use SilverStripe\Forms\DropdownField;
7
use SilverStripe\ORM\FieldType\DBField;
8
9
class ElementContent extends BaseElement
10
{
11
    private static $icon = 'font-icon-block-content';
0 ignored issues
show
Unused Code introduced by
The property $icon 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...
12
13
    private static $db = [
0 ignored issues
show
Unused Code introduced by
The property $db 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...
14
        'HTML' => 'HTMLText'
15
    ];
16
17
    private static $table_name = 'ElementContent';
0 ignored issues
show
Unused Code introduced by
The property $table_name 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...
18
19
    private static $singular_name = 'content block';
0 ignored issues
show
Unused Code introduced by
The property $singular_name 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...
20
21
    private static $plural_name = 'content blocks';
0 ignored issues
show
Unused Code introduced by
The property $plural_name 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...
22
23
    private static $description = 'HTML text block';
0 ignored issues
show
Unused Code introduced by
The property $description 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...
24
25
    /**
26
     * Re-title the HTML field to Content
27
     *
28
     * {@inheritDoc}
29
     */
30
    public function getCMSFields()
31
    {
32
        $this->beforeUpdateCMSFields(function ($fields) {
33
            $fields
34
                ->fieldByName('Root.Main.HTML')
35
                ->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content'));
36
        });
37
        return parent::getCMSFields();
38
    }
39
40
    public function getSummary()
41
    {
42
        return DBField::create_field('HTMLText', $this->HTML)->Summary(20);
0 ignored issues
show
Bug Best Practice introduced by
The property HTML does not exist on DNADesign\Elemental\Models\ElementContent. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
    }
44
45
    public function getType()
46
    {
47
        return _t(__CLASS__ . '.BlockType', 'Content');
48
    }
49
}
50