forked from unclecheese/silverstripe-gridfield-betterbuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterButton_Unpublish.php
executable file
·43 lines (37 loc) · 1.06 KB
/
BetterButton_Unpublish.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
38
39
40
41
42
43
<?php
namespace UncleCheese\BetterButtons\Buttons;
use UncleCheese\BetterButtons\Buttons\BetterButton;
use UncleCheese\BetterButtons\Interfaces\BetterButton_Versioned;
/**
* Defines the button that unpublishes a record
*
* @author Uncle Cheese <unclecheese@leftandmain.com>
* @package silverstripe-gridfield-betterbuttons
*/
class BetterButton_Unpublish extends BetterButton implements BetterButton_Versioned
{
/**
* Builds the button
*/
public function __construct()
{
parent::__construct('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'));
}
/**
* Adds a class to identify this as a destructive action
* @return void
*/
public function baseTransform()
{
parent::baseTransform();
return $this->addExtraClass('ss-ui-action-destructive');
}
/**
* Determines if the button should show
* @return boolean
*/
public function shouldDisplay()
{
return $this->gridFieldRequest->recordIsPublished() && $this->gridFieldRequest->record->canEdit();
}
}