base-rest-page-action.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Admin\Single_Pages\Actions; |
| 5 | |
| 6 | use Jet_Form_Builder\Admin\Pages\Actions\Base_Page_Action; |
| 7 | use Jet_Form_Builder\Rest_Api\Rest_Endpoint; |
| 8 | use Jet_Form_Builder\Rest_Api\Traits\Rest_Fetch_Endpoint; |
| 9 | |
| 10 | // If this file is called directly, abort. |
| 11 | if ( ! defined( 'WPINC' ) ) { |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | abstract class Base_Rest_Page_Action extends Base_Page_Action implements Rest_Fetch_Endpoint { |
| 16 | |
| 17 | public function get_payload(): array { |
| 18 | return array(); |
| 19 | } |
| 20 | |
| 21 | public function to_array(): array { |
| 22 | return parent::to_array() + array( |
| 23 | 'endpoint' => ( new Rest_Endpoint( $this ) )->to_array(), |
| 24 | 'payload' => $this->get_payload(), |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | } |
| 29 |