Code Duplication    Length = 19-23 lines in 2 locations

code/blocks/PageSectionBlock.php 1 location

@@ 36-54 (lines=19) @@
33
    /**
34
     * @return FieldList
35
     */
36
    public function getCMSFields()
37
    {
38
        $fields = parent::getCMSFields();
39
40
        if ($this->ID) {
41
            // Sections
42
            $config = GridFieldConfig_RecordEditor::create();
43
            $config->addComponent(new GridFieldOrderableRows('SortOrder'));
44
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
45
            $config->removeComponentsByType('GridFieldDeleteAction');
46
            $config->addComponent(new GridFieldDeleteAction(false));
47
            $sectionsField = GridField::create('Sections', 'Sections', $this->Sections()->sort('SortOrder'), $config);
48
            $fields->addFieldsToTab('Root.Sections', array(
49
                $sectionsField,
50
            ));
51
        }
52
53
        return $fields;
54
    }
55
56
    /**
57
     * @return mixed

code/blocks/PromoBlock.php 1 location

@@ 40-62 (lines=23) @@
37
    /**
38
     * @return FieldList
39
     */
40
    public function getCMSFields()
41
    {
42
        $fields = parent::getCMSFields();
43
44
        $fields->removeByName(array(
45
            'Promos',
46
        ));
47
48
        if ($this->ID) {
49
            $config = GridFieldConfig_RelationEditor::create();
50
            $config->addComponent(new GridFieldOrderableRows('SortOrder'));
51
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
52
            $config->addComponent(new GridFieldAddExistingSearchButton());
53
            $promos = $this->Promos()->sort('SortOrder');
54
            $promoField = GridField::create('Promos', 'Promos', $promos, $config);
55
56
            $fields->addFieldsToTab('Root.Promos', array(
57
                $promoField,
58
            ));
59
        }
60
61
        return $fields;
62
    }
63
64
    /**
65
     * @return mixed