| 1 |
<?php |
| 2 |
|
| 3 |
namespace JewelTheme\AdminBarEditor\Inc; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) exit; |
| 6 |
|
| 7 |
abstract class Base_Model extends Base_Data |
| 8 |
{ |
| 9 |
|
| 10 |
protected function init($data) |
| 11 |
{ |
| 12 |
$this->set(array_merge($this->get_defaults(), $data)); |
| 13 |
} |
| 14 |
|
| 15 |
public static function _get_defaults() |
| 16 |
{ |
| 17 |
return []; |
| 18 |
} |
| 19 |
|
| 20 |
public function get_default_field($field) |
| 21 |
{ |
| 22 |
$fields = $this->get_defaults(); |
| 23 |
return isset($fields[$field]) ? $fields[$field] : null; |
| 24 |
} |
| 25 |
|
| 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); |
| 35 |
} |
| 36 |
} |
| 37 |
|