Completed
Push — master ( 991aa3...ce6ba6 )
by
unknown
22s
created

FontPickerField::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CWP\AgencyExtensions\Forms;
4
5
use SilverStripe\Forms\SingleSelectField;
6
7
class FontPickerField extends SingleSelectField
8
{
9
    public function __construct($name, $title = null, $source = array(), $value = null)
10
    {
11
        parent::__construct($name, $title, $source, $value);
12
13
        $this->addExtraClass('font-picker-field');
14
    }
15
16
    public function getSchemaDataDefaults()
17
    {
18
        $schemaData = parent::getSchemaDataDefaults();
19
20
        $fonts = [];
21
        foreach ($this->getSource() as $css => $title) {
22
            $fonts[] = [
23
                'CSSClass' => $css,
24
                'Title' => $title,
25
            ];
26
        }
27
28
        $schemaData['source'] = $fonts;
29
        $schemaData['name'] = $this->getName();
30
        $schemaData['value'] = $this->Value();
31
32
        return $schemaData;
33
    }
34
}
35