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