| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImportWP\Common\Addon; |
| 4 |
|
| 5 |
/** |
| 6 |
* @deprecated 2.14.0 |
| 7 |
*/ |
| 8 |
class AddonDataApi |
| 9 |
{ |
| 10 |
protected $_addon; |
| 11 |
protected $_object_id; |
| 12 |
protected $_section_id; |
| 13 |
protected $_data; |
| 14 |
protected $_importer_model; |
| 15 |
protected $_template; |
| 16 |
|
| 17 |
/** |
| 18 |
* @param AddonBase $addon |
| 19 |
* @param string $object_id |
| 20 |
* @param string $section_id |
| 21 |
* @param string[] $data |
| 22 |
* @param ImporterModel $importer_model |
| 23 |
* @param \ImportWP\Common\Importer\Template\Template $template |
| 24 |
*/ |
| 25 |
public function __construct($addon, $object_id, $section_id, $data, $importer_model, $template) |
| 26 |
{ |
| 27 |
$this->_addon = $addon; |
| 28 |
$this->_object_id = $object_id; |
| 29 |
$this->_section_id = $section_id; |
| 30 |
$this->_data = $data; |
| 31 |
$this->_importer_model = $importer_model; |
| 32 |
$this->_template = $template; |
| 33 |
} |
| 34 |
|
| 35 |
public function addon() |
| 36 |
{ |
| 37 |
return $this->_addon; |
| 38 |
} |
| 39 |
|
| 40 |
public function object_id() |
| 41 |
{ |
| 42 |
return $this->_object_id; |
| 43 |
} |
| 44 |
|
| 45 |
public function section_id() |
| 46 |
{ |
| 47 |
return $this->_section_id; |
| 48 |
} |
| 49 |
|
| 50 |
public function data($key = false) |
| 51 |
{ |
| 52 |
if ($key) { |
| 53 |
return isset($this->_data[$key]) ? $this->_data[$key] : false; |
| 54 |
} |
| 55 |
return $this->_data; |
| 56 |
} |
| 57 |
|
| 58 |
public function importer_model() |
| 59 |
{ |
| 60 |
return $this->_importer_model; |
| 61 |
} |
| 62 |
|
| 63 |
public function template() |
| 64 |
{ |
| 65 |
return $this->_template; |
| 66 |
} |
| 67 |
|
| 68 |
public function get_mapper() |
| 69 |
{ |
| 70 |
return $this->template()->get_mapper(); |
| 71 |
} |
| 72 |
|
| 73 |
public function get_panel_id() |
| 74 |
{ |
| 75 |
return $this->section_id(); |
| 76 |
} |
| 77 |
|
| 78 |
public function get_meta($section_id = false) |
| 79 |
{ |
| 80 |
if ($section_id === false) { |
| 81 |
$section_id = $this->get_panel_id(); |
| 82 |
} |
| 83 |
|
| 84 |
return $this->addon()->get_meta($section_id); |
| 85 |
} |
| 86 |
|
| 87 |
public function store_meta($key, $value, $i = false) |
| 88 |
{ |
| 89 |
$this->addon()->store_meta($this->get_panel_id(), $this->object_id(), $key, $value, $i); |
| 90 |
} |
| 91 |
|
| 92 |
public function update_meta($key, $value, $is_unique = true) |
| 93 |
{ |
| 94 |
$this->addon()->update_meta($this->object_id(), $key, $value, $is_unique); |
| 95 |
} |
| 96 |
} |
| 97 |
|