Moo_EditableFieldHeading::getCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 4
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Moo_EditableFieldHeading is an object representing generic heading created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldHeading extends Moo_EditableField
11
{
12
    private static $singular_name   = 'Heading';
13
    private static $plural_name     = 'Headings';
14
15
    /**
16
     * List of allowed custom settings fields.
17
     *
18
     * @var array
19
     */
20
    protected $customSettingsFields = [
21
        'Level',
22
    ];
23
24
    public function getCMSFields()
25
    {
26
        $fields = parent::getCMSFields();
27
28
        // Remove validation tab & fields
29
        $fields->removeByName(['Root.Validation', 'Required', 'CustomErrorMessage']);
30
31
        return $fields;
32
    }
33
34
    /**
35
     * Get extra configuration fields.
36
     *
37
     * @return array
38
     */
39
    public function getFieldConfiguration()
40
    {
41
        $levels = [
42
            '1' => '1',
43
            '2' => '2',
44
            '3' => '3',
45
            '4' => '4',
46
            '5' => '5',
47
            '6' => '6',
48
        ];
49
50
        $level = ($this->getSetting('Level')) ? $this->getSetting('Level') : 3;
51
        $label = _t('Moo_EditableFieldHeading.LEVEL', 'Select Heading Level');
52
53
        return [
54
            new DropdownField($this->getSettingName('Level'), $label, $levels, $level),
55
        ];
56
    }
57
58 1
    protected function initFormField()
59
    {
60 1
        $labelField = new HeaderField($this->Name, $this->Title, $this->getSetting('Level'));
61 1
        $labelField->addExtraClass('FormHeading');
62
63 1
        return $labelField;
64
    }
65
}
66