Test Setup Failed
Pull Request — master (#197)
by Gorrie
01:07
created

src/Models/ElementContent.php (6 issues)

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
The private property $icon is not used, and could be removed.
Loading history...
12
13
    private static $db = [
14
        'HTML' => 'HTMLText'
15
    ];
16
17
    private static $table_name = 'ElementContent';
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
18
19
    private static $singular_name = 'content block';
0 ignored issues
show
The private property $singular_name is not used, and could be removed.
Loading history...
20
21
    private static $plural_name = 'content blocks';
0 ignored issues
show
The private property $plural_name is not used, and could be removed.
Loading history...
22
23
    private static $description = 'HTML text block';
0 ignored issues
show
The private property $description is not used, and could 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