Completed
Push — master ( 6a46b2...19407a )
by Franco
12s
created

DMSDocumentCartAdmin::getEditForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
class DMSDocumentCartAdmin extends ModelAdmin
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private static $managed_models = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $managed_models is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
        'DMSDocumentCartSubmission'
7
    );
8
9
    private static $url_segment = 'cart';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $url_segment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
    private static $menu_title = 'Document Cart';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $menu_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
12
    /**
13
     * Remove ability to add new items in these grid fields
14
     *
15
     * @return CMSForm
16
     */
17
    public function getEditForm($id = null, $fields = null)
18
    {
19
        /** @var CMSForm $form */
20
        $form = parent::getEditForm($id, $fields);
21
22
        // See parent class
23
        $gridFieldName = $this->sanitiseClassName($this->modelClass);
24
25
        $gridFieldConfig = $form->Fields()->fieldByName($gridFieldName)->getConfig();
26
        $gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
27
28
        return $form;
29
    }
30
}
31