actions
2 years ago
columns
2 years ago
column-advanced-base.php
2 years ago
column-base.php
2 years ago
column-heading-interface.php
2 years ago
column-heading-trait.php
2 years ago
view-advanced-base.php
2 years ago
view-base.php
2 years ago
view-simple-base.php
2 years ago
view-base.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Admin\Table_Views; |
| 5 | |
| 6 | use JFB_Components\Repository\Repository_Item_With_Class; |
| 7 | use JFB_Components\Repository\Repository_Static_Item_It; |
| 8 | use Jet_Form_Builder\Db_Queries\Exceptions\Sql_Exception; |
| 9 | use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies; |
| 10 | use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies_Interface; |
| 11 | use Jet_Form_Builder\Rest_Api\Rest_Endpoint; |
| 12 | use Jet_Form_Builder\Rest_Api\Traits\Rest_Fetch_Endpoint; |
| 13 | |
| 14 | // If this file is called directly, abort. |
| 15 | if ( ! defined( 'WPINC' ) ) { |
| 16 | die; |
| 17 | } |
| 18 | |
| 19 | abstract class View_Base implements |
| 20 | Repository_Static_Item_It, |
| 21 | Model_Dependencies_Interface, |
| 22 | Rest_Fetch_Endpoint { |
| 23 | |
| 24 | use Repository_Item_With_Class; |
| 25 | use Model_Dependencies; |
| 26 | |
| 27 | abstract public function get_prepared_list( array $custom_list = array() ): array; |
| 28 | |
| 29 | public function get_list(): array { |
| 30 | return $this->get_raw_list( |
| 31 | array( |
| 32 | 'offset' => 0, |
| 33 | 'limit' => 15, |
| 34 | ) |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | public function get_global_actions(): array { |
| 39 | return array(); |
| 40 | } |
| 41 | |
| 42 | public function get_total(): int { |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | public function get_empty_message(): string { |
| 47 | return __( 'No items found.', 'jet-form-builder' ); |
| 48 | } |
| 49 | |
| 50 | public function get_rest_methods(): string { |
| 51 | return ''; |
| 52 | } |
| 53 | |
| 54 | public function get_rest_url(): string { |
| 55 | return ''; |
| 56 | } |
| 57 | |
| 58 | public function get_receive_endpoint(): array { |
| 59 | return ( new Rest_Endpoint( $this ) )->to_array(); |
| 60 | } |
| 61 | |
| 62 | public function load_data(): array { |
| 63 | return array(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @return array |
| 68 | */ |
| 69 | final public function load_view(): array { |
| 70 | try { |
| 71 | $this->prepare_dependencies(); |
| 72 | } catch ( Sql_Exception $exception ) { |
| 73 | return array( |
| 74 | 'list' => array(), |
| 75 | 'columns' => array(), |
| 76 | 'actions' => array(), |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | return array_merge( |
| 81 | array( |
| 82 | 'list' => $this->get_prepared_list(), |
| 83 | 'columns' => $this->get_columns_headings(), |
| 84 | 'actions' => $this->get_global_actions(), |
| 85 | 'total' => $this->get_total(), |
| 86 | 'receive_url' => $this->get_receive_endpoint(), |
| 87 | 'empty_message' => $this->get_empty_message(), |
| 88 | ), |
| 89 | $this->load_data() |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | } |
| 95 |