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

ProductDocCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 33
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
    public function getCMSFields()
16
    {
17
        $fields = parent::getCMSFields();
18
19
        if ($relations = ClassInfo::subclassesFor('ProductDoc')) {
20
            unset($relations['ProductDoc']);
21
            foreach ($relations as $key => $value) {
22
                $relations[$key] = singleton($value)->i18n_singular_name();
23
            }
24
25
            $fields->addFieldToTab(
26
                'Root.Main',
27
                DropdownField::create('ManagedClass', 'Files to display', $relations)
28
                    ->setEmptyString(''),
29
                'Content'
30
            );
31
        }
32
33
        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
}