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

FontPickerField::getSchemaDataDefaults()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 17
rs 9.9332
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