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

ElementalGridFieldUnlinkAction::getColumnContent()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 3
nop 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->canDelete()) return;
10
11
        if(!$record instanceof ElementVirtualLinked) {
12
            $field = GridField_FormAction::create($gridField,
13
                    'UnlinkRelation'.$record->ID,
14
                    false,
15
                    'unlinkrelation',
16
                    array('RecordID' => $record->ID)
17
                )
18
                ->addExtraClass('gridfield-button-unlink')
19
                ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))
20
                ->setAttribute('data-icon', 'chain--minus');
21
22
            return $field->Field();
23
        }
24
    }
25
}
26