forked from micmania1/silverstripe-lumberjack
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathGridFieldSiteTreeEditButton.php
37 lines (32 loc) · 1.07 KB
/
GridFieldSiteTreeEditButton.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace SilverStripe\Lumberjack\Forms;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldEditButton;
use SilverStripe\ORM\DataObject;
use SilverStripe\Model\ArrayData;
/**
* Swaps the GridField Link out for the SiteTree edit link using {@link SiteTree::CMSEditLink()}.
*
* Bypasses GridFieldDetailForm
*
* @author Michael Strong <[email protected]>
**/
class GridFieldSiteTreeEditButton extends GridFieldEditButton
{
/**
* @param GridField $gridField
* @param DataObject $record
* @param string $columnName
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
// No permission checks - handled through GridFieldDetailForm
// which can make the form readonly if no edit permissions are available.
$data = ArrayData::create([
'Link' => $record->getCMSEditLink(),
'ExtraClass' => $this->getExtraClass(),
]);
return $data->renderWith(GridFieldEditButton::class);
}
}