Completed
Push — master ( 59c799...149ad0 )
by Will
02:15
created

ElementalGridFieldDeleteAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getColumnContent() 0 22 4
1
<?php
2
3
/**
4
 * @package elemental
5
 */
6
class ElementalGridFieldDeleteAction 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 instanceof ElementVirtualLinked) {
10
            if(!$record->canEdit()) return;
11
12
            $field = GridField_FormAction::create($gridField, 'UnlinkRelation'.$record->ID, false,
13
                    "unlinkrelation", array('RecordID' => $record->ID))
14
                ->addExtraClass('gridfield-button-unlink')
15
                ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))
16
                ->setAttribute('data-icon', 'chain--minus');
17
        } else {
18
            if(!$record->canDelete()) return;
19
20
            $field = GridField_FormAction::create($gridField,  'DeleteRecord'.$record->ID, false, "deleterecord",
21
                    array('RecordID' => $record->ID))
22
                ->addExtraClass('gridfield-button-delete')
23
                ->setAttribute('title', _t('GridAction.Delete', "Delete"))
24
                ->setAttribute('data-icon', 'cross-circle')
25
                ->setDescription(_t('GridAction.DELETE_DESCRIPTION','Delete'));
26
        }
27
28
        return $field->Field();
29
    }
30
}
31