Completed
Pull Request — master (#71)
by John
02:15
created

ElementalGridFieldUnlinkAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getColumnContent() 0 19 3
1
<?php
2
3
/**
4
 * @package elemental
5
 */
6
class ElementalGridFieldUnlinkAction extends GridFieldDeleteAction {
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...
7
8
    public function getColumnContent($gridField, $record, $columnName) {
9
        if(!$record->canEdit()) return;
10
11
        $field = new CompositeField();
12
13
        if(!$record instanceof ElementVirtualLinked) {
14
            $field = GridField_FormAction::create($gridField,
15
                    'UnlinkRelation'.$record->ID,
16
                    false,
17
                    'unlinkrelation',
18
                    array('RecordID' => $record->ID)
19
                )
20
                ->addExtraClass('gridfield-button-unlink')
21
                ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))
22
                ->setAttribute('data-icon', 'chain--minus');
23
        }
24
25
        return $field->Field();
26
    }
27
}
28