1 | <?php |
||
2 | |||
3 | namespace DNADesign\Elemental\Models; |
||
4 | |||
5 | use SilverStripe\Forms\FieldList; |
||
6 | use SilverStripe\Forms\HTMLEditor\HTMLEditorField; |
||
7 | use SilverStripe\ORM\FieldType\DBField; |
||
8 | |||
9 | /** |
||
10 | * @property string $HTML |
||
11 | */ |
||
12 | class ElementContent extends BaseElement |
||
13 | { |
||
14 | private static $icon = 'font-icon-block-content'; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
15 | |||
16 | private static $db = [ |
||
0 ignored issues
–
show
|
|||
17 | 'HTML' => 'HTMLText' |
||
18 | ]; |
||
19 | |||
20 | private static $table_name = 'ElementContent'; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | private static $singular_name = 'content block'; |
||
0 ignored issues
–
show
|
|||
23 | |||
24 | private static $plural_name = 'content blocks'; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | private static $description = 'HTML text block'; |
||
0 ignored issues
–
show
|
|||
27 | |||
28 | /** |
||
29 | * Re-title the HTML field to Content |
||
30 | * |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | public function getCMSFields() |
||
34 | { |
||
35 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
36 | /** @var HTMLEditorField $editorField */ |
||
37 | $editorField = $fields->fieldByName('Root.Main.HTML'); |
||
0 ignored issues
–
show
Are you sure the assignment to
$editorField is correct as $fields->fieldByName('Root.Main.HTML') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
38 | $editorField->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content')); |
||
39 | }); |
||
40 | |||
41 | return parent::getCMSFields(); |
||
42 | } |
||
43 | |||
44 | public function getSummary() |
||
45 | { |
||
46 | return DBField::create_field('HTMLText', $this->HTML)->Summary(20); |
||
47 | } |
||
48 | |||
49 | protected function provideBlockSchema() |
||
50 | { |
||
51 | $blockSchema = parent::provideBlockSchema(); |
||
52 | $blockSchema['content'] = $this->getSummary(); |
||
53 | return $blockSchema; |
||
54 | } |
||
55 | |||
56 | public function getType() |
||
57 | { |
||
58 | return _t(__CLASS__ . '.BlockType', 'Content'); |
||
59 | } |
||
60 | } |
||
61 |