Passed
Pull Request — master (#51)
by Robbie
03:18
created

ResourceDropdownFilter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 12 1
1
<?php
2
3
namespace SilverStripe\CKANRegistry\Model;
4
5
use SilverStripe\Forms\DropdownField;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\TextField;
8
9
class ResourceDropdownFilter extends ResourceFilter
10
{
11
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
12
        'Options' => 'Varchar'
13
    ];
14
15
    private static $singular_name = 'Dropdown Filter';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
16
17
    protected $fieldType = DropdownField::class;
18
19
    public function getCMSFields()
20
    {
21
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
22
            $fields->push(TextField::create(
23
                'Options',
24
                _t(__CLASS__ . '.Options', 'Dropdown options')
25
            ));
26
27
            $fields->removeByName('FilterForID');
28
        });
29
30
        return parent::getCMSFields();
31
    }
32
}
33