api-single-action.php
3 years ago
link-single-action.php
3 years ago
view-single-action.php
3 years ago
api-single-action.php
28 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Admin\Table_Views\Actions; |
| 5 | |
| 6 | |
| 7 | abstract class Api_Single_Action extends View_Single_Action { |
| 8 | |
| 9 | abstract public function get_method(): string; |
| 10 | |
| 11 | abstract public function get_rest_url( array $record ): string; |
| 12 | |
| 13 | public function get_payload( array $record ): array { |
| 14 | return array(); |
| 15 | } |
| 16 | |
| 17 | public function to_array( array $record ): array { |
| 18 | $attrs = parent::to_array( $record ); |
| 19 | |
| 20 | $attrs['payload'] = $this->get_payload( $record ); |
| 21 | $attrs['endpoint'] = array( |
| 22 | 'method' => $this->get_method(), |
| 23 | 'url' => $this->get_rest_url( $record ), |
| 24 | ); |
| 25 | |
| 26 | return $attrs; |
| 27 | } |
| 28 | } |