Passed
Pull Request — master (#51)
by Robbie
02:40
created

Dropdown   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 24
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\ResourceFilter;
4
5
use SilverStripe\CKANRegistry\Model\ResourceFilter;
6
use SilverStripe\Forms\DropdownField;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\TextField;
9
10
/**
11
 * Provides a single select option for CKAN resources to be filtered by
12
 */
13
class Dropdown extends ResourceFilter
14
{
15
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
16
        'Options' => 'Varchar',
17
    ];
18
19
    private static $table_name = 'CKANFilter_Dropdown';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
20
21
    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...
22
23
    protected $fieldType = DropdownField::class;
24
25
    public function getCMSFields()
26
    {
27
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
28
            $fields->push(TextField::create(
29
                'Options',
30
                _t(__CLASS__ . '.Options', 'Dropdown options')
31
            ));
32
33
            $fields->removeByName('FilterForID');
34
        });
35
36
        return parent::getCMSFields();
37
    }
38
}
39