Completed
Pull Request — master (#30)
by Jason
17:47 queued 02:47
created

ProductDocCollection::getCMSFields()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
nc 2
nop 0
dl 0
loc 19
rs 9.4285
c 1
b 0
f 0
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
9
class ProductDocCollection extends \Page
0 ignored issues
show
Bug introduced by
The type Page 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...
10
{
11
    /**
12
     * @var array
13
     */
14
    private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
15
        'ManagedClass' => 'Varchar(255)',
16
    );
17
18
    /**
19
     * @var string
20
     */
21
    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...
22
23
    /**
24
     * @return FieldList
0 ignored issues
show
Bug introduced by
The type Dynamic\ProductCatalog\Page\FieldList 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...
25
     */
26
    public function getCMSFields()
27
    {
28
        $fields = parent::getCMSFields();
29
30
        if ($relations = ClassInfo::subclassesFor(ProductDoc::class)) {
31
            unset($relations[ProductDoc::class]);
32
            foreach ($relations as $key => $value) {
33
                $relations[$key] = singleton($value)->i18n_singular_name();
34
            }
35
36
            $fields->addFieldToTab(
37
                'Root.Main',
38
                DropdownField::create('ManagedClass', 'Files to display', $relations)
0 ignored issues
show
Bug introduced by
'ManagedClass' of type string is incompatible with the type array expected by parameter $args of SilverStripe\View\ViewableData::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
                DropdownField::create(/** @scrutinizer ignore-type */ 'ManagedClass', 'Files to display', $relations)
Loading history...
39
                    ->setEmptyString(''),
40
                'Content'
41
            );
42
        }
43
44
        return $fields;
45
    }
46
}
47