1 | <?php |
||
8 | class BatchActions extends AbstractTool |
||
9 | { |
||
10 | /** |
||
11 | * @var Collection |
||
12 | */ |
||
13 | protected $actions; |
||
14 | |||
15 | /** |
||
16 | * @var bool |
||
17 | */ |
||
18 | protected $enableDelete = true; |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $holdAll = false; |
||
24 | |||
25 | /** |
||
26 | * BatchActions constructor. |
||
27 | */ |
||
28 | public function __construct() |
||
34 | |||
35 | /** |
||
36 | * Append default action(batch delete action). |
||
37 | * |
||
38 | * return void |
||
39 | */ |
||
40 | protected function appendDefaultAction() |
||
44 | |||
45 | /** |
||
46 | * Disable delete. |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | public function disableDelete(bool $disable = true) |
||
51 | { |
||
52 | $this->enableDelete = !$disable; |
||
53 | |||
54 | return $this; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Disable delete And Hode SelectAll Checkbox. |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | public function disableDeleteAndHodeSelectAll() |
||
70 | |||
71 | /** |
||
72 | * Add a batch action. |
||
73 | * |
||
74 | * @param $title |
||
75 | * @param BatchAction|null $action |
||
76 | * |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function add($title, BatchAction $action = null) |
||
97 | |||
98 | /** |
||
99 | * Setup scripts of batch actions. |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | protected function addActionScripts() |
||
113 | |||
114 | /** |
||
115 | * Render BatchActions button groups. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | public function render() |
||
134 | } |
||
135 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: