| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Base class |
| 5 |
* |
| 6 |
* @since 3.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
// Load library classes |
| 10 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.class.php' ); |
| 11 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.Admin.class.php' ); |
| 12 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.AdminCustomerForm.class.php' ); |
| 13 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.AdminOrderForm.class.php' ); |
| 14 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.AdminSalesRepForm.class.php' ); |
| 15 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.CustomerForm.class.php' ); |
| 16 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.CustomerOrderForm.class.php' ); |
| 17 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.OrderForm.class.php' ); |
| 18 |
require_once( EWD_OTP_PLUGIN_DIR . '/views/View.SalesRepForm.class.php' ); |
| 19 |
|
| 20 |
class ewdotpBase { |
| 21 |
|
| 22 |
public $id = null; |
| 23 |
|
| 24 |
// Collect errors during processing |
| 25 |
public $errors = array(); |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* Initialize the class |
| 30 |
* @since 3.0.0 |
| 31 |
*/ |
| 32 |
public function __construct( $args ) { |
| 33 |
|
| 34 |
// Parse the values passed |
| 35 |
$this->parse_args( $args ); |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Parse the arguments passed in the construction and assign them to |
| 41 |
* internal variables. |
| 42 |
* @since 3.0.0 |
| 43 |
*/ |
| 44 |
public function parse_args( $args ) { |
| 45 |
foreach ( $args as $key => $val ) { |
| 46 |
switch ( $key ) { |
| 47 |
|
| 48 |
case 'id' : |
| 49 |
$this->{$key} = esc_attr( $val ); |
| 50 |
|
| 51 |
default : |
| 52 |
$this->{$key} = $val; |
| 53 |
|
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Set an error |
| 60 |
* @since 3.0.0 |
| 61 |
*/ |
| 62 |
public function set_error( $error ) { |
| 63 |
$this->errors[] = array_merge( |
| 64 |
$error, |
| 65 |
array( |
| 66 |
'class' => get_class( $this ), |
| 67 |
'id' => $this->id, |
| 68 |
'backtrace' => debug_backtrace() |
| 69 |
) |
| 70 |
); |
| 71 |
} |
| 72 |
|
| 73 |
} |
| 74 |
|