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

DMSGridFieldEditButton::getColumnContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
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 implements GridField_ColumnProvider
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
    /**
7
     * Overriding the parent method to change the template that the DMS edit button will be rendered with
8
     *
9
     * @param GridField $gridField
10
     * @param DataObject $record
11
     * @param string $columnName
12
     *
13
     * @return string - the HTML for the column
0 ignored issues
show
Documentation introduced by
Should the return type not be HTMLText?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
14
     */
15
    public function getColumnContent($gridField, $record, $columnName)
16
    {
17
        $data = new ArrayData(array(
18
            'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
19
        ));
20
21
        $template = $record->canEdit() ? 'GridFieldEditButton' : 'GridFieldViewButton';
22
23
        return $data->renderWith($template);
24
    }
25
}
26