| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImportWP\Common\Addon; |
| 4 |
|
| 5 |
/** |
| 6 |
* @deprecated 2.14.0 |
| 7 |
*/ |
| 8 |
class AddonBaseGroup extends AddonBaseContainer implements AddonGroupInterface |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @var callable |
| 12 |
*/ |
| 13 |
protected $_process_callback; |
| 14 |
|
| 15 |
protected $_is_field_processable = false; |
| 16 |
|
| 17 |
protected $_id; |
| 18 |
|
| 19 |
public function _enable_processing() |
| 20 |
{ |
| 21 |
$this->_is_field_processable = true; |
| 22 |
} |
| 23 |
|
| 24 |
public function _is_processing_enabled() |
| 25 |
{ |
| 26 |
return $this->_is_field_processable; |
| 27 |
} |
| 28 |
|
| 29 |
public function __construct($addon, $id, $data) |
| 30 |
{ |
| 31 |
$this->_id = $id; |
| 32 |
parent::__construct($addon, array_merge($data, ['type' => 'group'])); |
| 33 |
} |
| 34 |
|
| 35 |
public function _process($object_id, $data, $importer_model, $template) |
| 36 |
{ |
| 37 |
if (!is_null($this->_process_callback) && is_callable($this->_process_callback)) { |
| 38 |
call_user_func($this->_process_callback, new AddonGroupDataApi($this->addon(), $this, $object_id, $this->get_id(), $data, $importer_model, $template)); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
public function save($callback) |
| 43 |
{ |
| 44 |
$this->_process_callback = $callback; |
| 45 |
return $this; |
| 46 |
} |
| 47 |
|
| 48 |
public function get_id() |
| 49 |
{ |
| 50 |
return $this->_id; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @return AddonBaseField[] |
| 55 |
*/ |
| 56 |
public function fields() |
| 57 |
{ |
| 58 |
return isset($this->_data['fields']) ? $this->_data['fields'] : []; |
| 59 |
} |
| 60 |
} |
| 61 |
|