Completed
Push — master ( 1f0706...385015 )
by Franco
15s queued 10s
created

DMSDocumentAdmin::getEditForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
class DMSDocumentAdmin 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
        'DMSDocument'
7
    );
8
9
    private static $url_segment = 'documents';
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
11
    private static $menu_title = 'Documents';
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...
12
13
    /**
14
     * Remove the default "add" button and replace it with a customised version for DMS
15
     *
16
     * @return CMSForm
17
     */
18
    public function getEditForm($id = null, $fields = null)
19
    {
20
        /** @var CMSForm $form */
21
        $form = parent::getEditForm($id, $fields);
22
23
        // See parent class
24
        $gridFieldName = $this->sanitiseClassName($this->modelClass);
25
26
        $gridFieldConfig = $form->Fields()->fieldByName($gridFieldName)->getConfig();
27
        $gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
28
        $gridFieldConfig->addComponent(new DMSGridFieldAddNewButton('buttons-before-left'), 'GridFieldExportButton');
29
30
        return $form;
31
    }
32
}
33