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

DMSGridFieldEditButton::getColumnContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 3
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