1 | <?php |
||
8 | class Tools implements Renderable |
||
9 | { |
||
10 | /** |
||
11 | * The panel that holds this tool. |
||
12 | * |
||
13 | * @var Panel |
||
14 | */ |
||
15 | protected $panel; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $resource; |
||
21 | |||
22 | /** |
||
23 | * Default tools. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $tools = ['delete', 'list', 'edit']; |
||
28 | |||
29 | /** |
||
30 | * Tools should be appends to default tools. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $appends = []; |
||
35 | |||
36 | /** |
||
37 | * Tools should be prepends to default tools. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $prepends = []; |
||
42 | |||
43 | /** |
||
44 | * Tools constructor. |
||
45 | * |
||
46 | * @param Panel $panel |
||
47 | */ |
||
48 | public function __construct(Panel $panel) |
||
52 | |||
53 | /** |
||
54 | * Append a tools. |
||
55 | * |
||
56 | * @param mixed $tool |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function append($tool) |
||
66 | |||
67 | /** |
||
68 | * Prepend a tool. |
||
69 | * |
||
70 | * @param mixed $tool |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function prepend($tool) |
||
80 | |||
81 | /** |
||
82 | * Get resource path. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getResource() |
||
94 | |||
95 | /** |
||
96 | * Disable `list` tool. |
||
97 | * |
||
98 | * @return $this |
||
99 | */ |
||
100 | public function disableList() |
||
106 | |||
107 | /** |
||
108 | * Disable `delete` tool. |
||
109 | * |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function disableDelete() |
||
118 | |||
119 | /** |
||
120 | * Disable `edit` tool. |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | public function disableEdit() |
||
130 | |||
131 | /** |
||
132 | * Get request path for resource list. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function getListPath() |
||
140 | |||
141 | /** |
||
142 | * Get request path for edit. |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | protected function getEditPath() |
||
152 | |||
153 | /** |
||
154 | * Get request path for delete. |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | protected function getDeletePath() |
||
164 | |||
165 | /** |
||
166 | * Render `list` tool. |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | protected function renderList() |
||
180 | |||
181 | /** |
||
182 | * Render `edit` tool. |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | protected function renderEdit() |
||
196 | |||
197 | /** |
||
198 | * Render `delete` tool. |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | protected function renderDelete() |
||
258 | |||
259 | /** |
||
260 | * Render tools. |
||
261 | * |
||
262 | * @return string |
||
263 | */ |
||
264 | public function render() |
||
275 | } |
||
276 |