forked from unclecheese/silverstripe-gridfield-betterbuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterButton_PublishAndAdd.php
executable file
·36 lines (31 loc) · 1.06 KB
/
BetterButton_PublishAndAdd.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
<?php
namespace UncleCheese\BetterButtons\Buttons;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
use UncleCheese\BetterButtons\Buttons\BetterButton_SaveAndAdd;
use UncleCheese\BetterButtons\Interfaces\BetterButton_Versioned;
/**
* Defines the button that publishes a record, then proceeds to create a new one
*
* @author Uncle Cheese <unclecheese@leftandmain.com>
* @package silverstripe-gridfield-betterbuttons
*/
class BetterButton_PublishAndAdd extends BetterButton_SaveAndAdd implements BetterButton_Versioned
{
/**
* Builds the button
*/
public function __construct(Form $form, GridFieldDetailForm_ItemRequest $request)
{
return parent::__construct('doPublishAndAdd', _t('GridFieldDetailForm.PUBLISHANDADD', 'Publish and add new'));
}
/**
* Determines if the button should display
* @return boolean
*/
public function shouldDisplay()
{
$record = $this->gridFieldRequest->record;
return $record->canEdit() && $record->canCreate();
}
}