PageSectionBlock::singular_name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * Class PageSectionBlock
5
 *
6
 * @method HasManyList $Sections
7
 */
8 View Code Duplication
class PageSectionBlock extends Block
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @return string
12
     */
13 12
    public function singular_name()
14
    {
15 12
        return _t('PageSectionBlock.SINGULARNAME', 'Page Sections Block');
16
    }
17
18
    /**
19
     * @return string
20
     */
21 1
    public function plural_name()
22
    {
23 1
        return _t('PageSectionBlock.PLURALNAME', 'Page Sections Blocks');
24
    }
25
26
    /**
27
     * @var array
28
     */
29
    private static $has_many = [
30
        'Sections' => 'PageSectionObject',
31
    ];
32
33
    /**
34
     * @return FieldList
35
     */
36 1
    public function getCMSFields()
37
    {
38 1
        $fields = parent::getCMSFields();
39
40 1
        if ($this->ID) {
41
            // Sections
42 1
            $config = GridFieldConfig_RecordEditor::create();
43 1
            $config->addComponent(new GridFieldOrderableRows('SortOrder'));
44 1
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
45 1
            $config->removeComponentsByType('GridFieldDeleteAction');
46 1
            $config->addComponent(new GridFieldDeleteAction(false));
47 1
            $sectionsField = GridField::create('Sections', 'Sections', $this->Sections()->sort('SortOrder'), $config);
0 ignored issues
show
Bug introduced by
The method Sections() does not exist on PageSectionBlock. Did you maybe mean getPageSections()?

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...
48 1
            $fields->addFieldsToTab('Root.Sections', array(
49 1
                $sectionsField,
50 1
            ));
51 1
        }
52
53 1
        return $fields;
54
    }
55
56
    /**
57
     * @return mixed
58
     */
59 1
    public function getPageSections()
60
    {
61 1
        return $this->Sections()->sort('SortOrder');
0 ignored issues
show
Bug introduced by
The method Sections() does not exist on PageSectionBlock. Did you maybe mean getPageSections()?

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...
62
    }
63
}