Completed
Push — master ( d001a9...e5c7d1 )
by Robbie
27s queued 18s
created

DMSGridFieldEditButton   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getColumnContent() 0 10 2
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 based on
8
     * whether or not the user has edit permissions.
9
     *
10
     * @param GridField $gridField
11
     * @param DataObject $record
12
     * @param string $columnName
13
     *
14
     * @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...
15
     */
16
    public function getColumnContent($gridField, $record, $columnName)
17
    {
18
        $data = new ArrayData(array(
19
            'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
20
        ));
21
22
        $template = $record->canEdit() ? 'GridFieldEditButton' : 'GridFieldViewButton';
23
24
        return $data->renderWith($template);
25
    }
26
}
27