| @@ -1,25 +1,36 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc; | |
| 3 | +namespace WPAdminify\Inc; | |
| 4 | 4 | |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | - exit; | |
| 7 | -} | |
| 5 | +if (!defined('ABSPATH')) exit; | |
| 8 | 6 | |
| 9 | -abstract class Base_Model extends Base_Data { | |
| 7 | +abstract class Base_Model extends Base_Data | |
| 8 | +{ | |
| 10 | 9 | |
| 11 | - protected function init( $data ) { | |
| 12 | - $this->set( array_merge( $this->get_defaults(), $data ) ); | |
| 10 | + protected function init($data) | |
| 11 | + { | |
| 12 | + $this->set(array_merge($this->get_defaults(), $data)); | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function get_default_field( $field ) { | |
| 15 | + public static function _get_defaults() | |
| 16 | + { | |
| 17 | + return []; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public function get_default_field($field) | |
| 21 | + { | |
| 16 | 22 | $fields = $this->get_defaults(); |
| 17 | - return isset( $fields[ $field ] ) ? $fields[ $field ] : null; | |
| 23 | + return isset($fields[$field]) ? $fields[$field] : null; | |
| 18 | 24 | } |
| 19 | 25 | |
| 20 | - public function __construct( $data ) { | |
| 21 | - if ( $data ) { | |
| 22 | - $this->init( $data ); | |
| 23 | - } | |
| 26 | + public static function _get_default_field($field) | |
| 27 | + { | |
| 28 | + $fields = self::_get_defaults(); | |
| 29 | + return isset($fields[$field]) ? $fields[$field] : null; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public function __construct($data) | |
| 33 | + { | |
| 34 | + if ($data) $this->init($data); | |
| 24 | 35 | } |
| 25 | 36 | } |