Completed
Pull Request — master (#168)
by Franco
02:23
created

DMSGridFieldEditButton   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getColumnContent() 0 8 2
1
<?php
2
3
class DMSGridFieldEditButton extends GridFieldEditButton
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
    /**
6
     * Overriding the parent method to change the template that the edit button will be rendered with
7
     *
8
     * @param GridField $gridField
9
     * @param DataObject $record
10
     * @param string $columnName
11
     * @return HTMLText
12
     */
13
    public function getColumnContent($gridField, $record, $columnName)
14
    {
15
        $data = new ArrayData(array(
16
            'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
17
        ));
18
        $template = $record->canEdit() ? 'GridFieldEditButton' : 'GridFieldViewButton';
19
        return $data->renderWith($template);
20
    }
21
}
22