getFieldConfiguration()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
crap 12
1
<?php
2
3
/**
4
 * Moo_EditableFieldMemberList is an object representing member dropdown field created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldMemberList extends Moo_EditableField
11
{
12
    private static $singular_name   = 'Member List Field';
13
    private static $plural_name     = 'Member List Fields';
14
15
    /**
16
     * List of allowed custom settings fields.
17
     *
18
     * @var array
19
     */
20
    protected $customSettingsFields = [
21
        'GroupID',
22
    ];
23
24
    /**
25
     * Get extra configuration fields.
26
     *
27
     * @return array
28
     */
29
    public function getFieldConfiguration()
30
    {
31
        $groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0;
32
        $groups  = DataObject::get('Group');
33
34
        if ($groups) {
35
            $groups = $groups->map('ID', 'Title');
36
        }
37
38
        return [
39
            new DropdownField($this->getSettingName('GroupID'), _t('Moo_EditableField.GROUP', 'Group'), $groups, $groupID),
40
        ];
41
    }
42
43 1 View Code Duplication
    protected function initFormField()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 1
        if ($this->getSetting('GroupID')) {
46 1
            $members = Member::map_in_groups($this->getSetting('GroupID'));
47
48 1
            return new DropdownField($this->Name, $this->Title, $members);
49
        }
50
51
        return false;
52
    }
53
}
54