Completed
Pull Request — master (#5)
by Jason
06:46
created

ProductDocCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 20 3
1
<?php
2
3
class ProductDocCollection extends Page
4
{
5
    /**
6
     * @var array
7
     */
8
    private static $db = array(
9
        'ManagedClass' => 'Varchar(255)',
10
    );
11
12
    /**
13
     * @return FieldList
14
     */
15 1
    public function getCMSFields()
16
    {
17 1
        $fields = parent::getCMSFields();
18
19 1
        if ($relations = ClassInfo::subclassesFor('ProductDoc')) {
20 1
            unset($relations['ProductDoc']);
21 1
            foreach ($relations as $key => $value) {
22 1
                $relations[$key] = singleton($value)->i18n_singular_name();
23 1
            }
24
25 1
            $fields->addFieldToTab(
26 1
                'Root.Main',
27 1
                DropdownField::create('ManagedClass', 'Files to display', $relations)
28 1
                    ->setEmptyString(''),
29
                'Content'
30 1
            );
31 1
        }
32
33 1
        return $fields;
34
    }
35
}
36
37
class ProductDocCollection_Controller extends Page_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
38
{
39
40
}