GridFieldCustomLink::getLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
namespace LeKoala\CmsActions;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Forms\GridField\GridField;
7
use SilverStripe\ORM\DataObject;
8
9
/**
10
 * Expose a custom link in a GridField at row level
11
 * Action must be declared in getCMSActions to work
12
 */
13
class GridFieldCustomLink extends GridFieldRowLink
14
{
15
    /**
16
     * @param GridField $gridField
17
     * @param DataObject $record
18
     * @param string $columnName
19
     * @return string The link to the action
20
     */
21
    public function getLink($gridField, $record, $columnName)
22
    {
23
        return Controller::join_links($gridField->Link('item'), $record->ID, 'doCustomLink') . '?CustomLink=' . $this->name;
24
    }
25
}
26