ProductDocCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 36
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 19 3
1
<?php
2
3
namespace Dynamic\ProductCatalog\Page;
4
5
use Dynamic\ProductCatalog\Docs\ProductDoc;
6
use SilverStripe\Core\ClassInfo;
7
use SilverStripe\Forms\DropdownField;
8
use SilverStripe\Forms\FieldList;
9
10
class ProductDocCollection extends \Page
11
{
12
    /**
13
     * @var array
14
     */
15
    private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
16
        'ManagedClass' => 'Varchar(255)',
17
    );
18
19
    /**
20
     * @var string
21
     */
22
    private static $table_name = 'ProductDocCollection';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
23
24
    /**
25
     * @return FieldList
26
     */
27 1
    public function getCMSFields()
28
    {
29 1
        $fields = parent::getCMSFields();
30
31 1
        if ($relations = ClassInfo::subclassesFor(ProductDoc::class)) {
32 1
            unset($relations[ProductDoc::class]);
33 1
            foreach ($relations as $key => $value) {
34 1
                $relations[$key] = singleton($value)->i18n_singular_name();
35
            }
36
37 1
            $fields->addFieldToTab(
38 1
                'Root.Main',
39 1
                DropdownField::create('ManagedClass', 'Files to display', $relations)
40 1
                    ->setEmptyString(''),
41 1
                'Content'
42
            );
43
        }
44
45 1
        return $fields;
46
    }
47
}
48