ProductFileCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 15
c 1
b 0
f 0
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 19 3
1
<?php
2
3
namespace Dynamic\Products\Page;
4
5
use Dynamic\ProductCatalog\Docs\ProductDoc;
0 ignored issues
show
Bug introduced by
The type Dynamic\ProductCatalog\Docs\ProductDoc was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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