FlexBlock::getBlockSummary()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Cita\Modular\Model;
4
5
use SilverStripe\View\Parsers\ShortcodeParser;
6
use SilverStripe\ORM\FieldType\DBHTMLText;
7
use Cita\Modular\Traits\ModularCommonTrait;
8
use SilverStripe\Forms\FieldList;
9
10
class FlexBlock extends Block
11
{
12
    use ModularCommonTrait;
13
    /**
14
     * Defines the database table name
15
     *  @var string
16
     */
17
    private static $table_name = 'Cita_Modular_FlexBlock';
18
19
    private static $icon_class = 'font-icon-columns';
20
21
    /**
22
     * Singular name for CMS
23
     *  @var string
24
     */
25
    private static $singular_name = 'Flex block';
26
27
    /**
28
     * Many_many relationship
29
     * @var array
30
     */
31
    private static $many_many = [
32
        'ModularBlocks' => Block::class,
33
    ];
34
35
    /**
36
     * Defines Database fields for the Many_many bridging table
37
     *  @var array
38
     */
39
    private static $many_many_extraFields = [
40
        'ModularBlocks' => [
41
            'SortOrder' => 'Int',
42
            'ColOffset' => 'Varchar(8)',
43
            'ColSize' => 'Varchar(8)',
44
            'ColOffsetSm' => 'Varchar(8)',
45
            'ColSizeSm' => 'Varchar(8)',
46
            'ColOffsetMd' => 'Varchar(8)',
47
            'ColSizeMd' => 'Varchar(8)',
48
            'ColOffsetLg' => 'Varchar(8)',
49
            'ColSizeLg' => 'Varchar(8)',
50
        ],
51
    ];
52
53
    /**
54
     * CMS Fields
55
     * @return FieldList
56
     */
57
    public function getCMSFields()
58
    {
59
        $fields = parent::getCMSFields();
60
61
        $this->makeGridField($fields);
62
63
        return $fields;
64
    }
65
66
    public function getPlain()
67
    {
68
        return "<h2>" . $this->Title . "</h2>" . $this->Content;
69
    }
70
71
    public function getBlockSummary()
72
    {
73
        return DBHTMLText::create()->setValue(strip_tags(ShortcodeParser::get_active()->parse($this->Content)))->Summary(15);
74
    }
75
}
76