1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\CmsActions\Test; |
4
|
|
|
|
5
|
|
|
use LeKoala\CmsActions\ActionButtonsGroup; |
6
|
|
|
use LeKoala\CmsActions\CustomAction; |
7
|
|
|
use SilverStripe\Dev\TestOnly; |
8
|
|
|
use SilverStripe\Forms\FieldList; |
9
|
|
|
use SilverStripe\ORM\DataObject; |
10
|
|
|
|
11
|
|
|
class Test_CmsActionsModel extends DataObject implements TestOnly |
12
|
|
|
{ |
13
|
|
|
private static $db = [ |
|
|
|
|
14
|
|
|
"Name" => "Varchar", |
15
|
|
|
]; |
16
|
|
|
private static $has_one = []; |
|
|
|
|
17
|
|
|
private static $table_name = 'CmsActionsModel'; |
|
|
|
|
18
|
|
|
|
19
|
|
|
public function getCMSActions() |
20
|
|
|
{ |
21
|
|
|
$actions = parent::getCMSActions(); |
22
|
|
|
$actions->push(new CustomAction('testAction', 'Test Action')); |
23
|
|
|
|
24
|
|
|
$groupedButtons = [ |
25
|
|
|
new CustomAction("groupedAction1", "Grouped Action 1"), |
26
|
|
|
new CustomAction("groupedAction2", "Grouped Action 2"), |
27
|
|
|
]; |
28
|
|
|
$btnGroup = new ActionButtonsGroup($groupedButtons); |
29
|
|
|
$actions->push($btnGroup); |
30
|
|
|
|
31
|
|
|
return $actions; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getCMSUtils() |
35
|
|
|
{ |
36
|
|
|
$utils = new FieldList(); |
37
|
|
|
return $utils; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function canDelete($member = null) |
41
|
|
|
{ |
42
|
|
|
return true; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function canEdit($member = null) |
46
|
|
|
{ |
47
|
|
|
return true; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testAction() |
51
|
|
|
{ |
52
|
|
|
return 'called testAction'; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function groupedAction1() |
56
|
|
|
{ |
57
|
|
|
return 'called groupedAction1'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function groupedAction2() |
61
|
|
|
{ |
62
|
|
|
return 'called groupedAction2'; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getDeleteButtonTitle() |
66
|
|
|
{ |
67
|
|
|
return 'Delete this!'; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getCancelButtonTitle() |
71
|
|
|
{ |
72
|
|
|
return 'Maybe not!'; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|