updateCMSFields()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 17.8

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 3
cts 15
cp 0.2
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 11
nc 4
nop 1
crap 17.8
1
<?php
2
3
class DynamicBlocksSiteTreeDataExtension extends DataExtension
4
{
5
    /**
6
     * @param FieldList $fields
7
     */
8 1
    public function updateCMSFields(FieldList $fields)
9
    {
10 1
        if ($blocks = $fields->dataFieldByName('Blocks')) {
11
            $config = $blocks->getConfig();
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
12
13
            if ($this->owner->blockManager) {
14
                $areas = $this->owner->blockManager->getAreasForPageType($this->owner->ClassName);
15
16
                if ($areas && count($areas)) {
17
                    $config->addComponent(new GridFieldGroupable(
18
                        'BlockArea',
19
                        'Area',
20
                        'none',
21
                        $areas
22
                    ));
23
                }
24
            }
25
        }
26
    }
27
}