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

FontPickerField   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchemaDataDefaults() 0 17 2
A __construct() 0 5 1
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