| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Modules\Gateways\Meta_Boxes; |
| 5 |
|
| 6 |
use Jet_Form_Builder\Admin\Exceptions\Empty_Box_Exception; |
| 7 |
use Jet_Form_Builder\Admin\Exceptions\Not_Found_Page_Exception; |
| 8 |
use Jet_Form_Builder\Admin\Single_Pages\Meta_Boxes\Base_List_Box; |
| 9 |
use Jet_Form_Builder\Exceptions\Query_Builder_Exception; |
| 10 |
use JFB_Modules\Gateways\Meta_Boxes\Columns\Payer_Email_Column; |
| 11 |
use JFB_Modules\Gateways\Meta_Boxes\Columns\Payer_First_Name_Column; |
| 12 |
use JFB_Modules\Gateways\Meta_Boxes\Columns\Payer_Last_Name_Column; |
| 13 |
use JFB_Modules\Gateways\Query_Views\Payment_View; |
| 14 |
|
| 15 |
// If this file is called directly, abort. |
| 16 |
if ( ! defined( 'WPINC' ) ) { |
| 17 |
die; |
| 18 |
} |
| 19 |
|
| 20 |
class Payer_Box extends Base_List_Box { |
| 21 |
|
| 22 |
public function get_title(): string { |
| 23 |
return __( 'Payer Info', 'jet-form-builder' ); |
| 24 |
} |
| 25 |
|
| 26 |
public function get_columns(): array { |
| 27 |
return array( |
| 28 |
'first_name' => new Payer_First_Name_Column(), |
| 29 |
'last_name' => new Payer_Last_Name_Column(), |
| 30 |
'email' => new Payer_Email_Column(), |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @return array |
| 36 |
* @throws Empty_Box_Exception |
| 37 |
*/ |
| 38 |
public function get_list(): array { |
| 39 |
try { |
| 40 |
$payment = Payment_View::findById( $this->get_id() ); |
| 41 |
|
| 42 |
return $payment['payer'] ?? array(); |
| 43 |
} catch ( Query_Builder_Exception $exception ) { |
| 44 |
throw new Empty_Box_Exception( |
| 45 |
esc_html( $exception->getMessage() ), |
| 46 |
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped |
| 47 |
...$exception->get_additional() |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|