| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImportWP\Common\Addon; |
| 4 |
|
| 5 |
use ImportWP\Container; |
| 6 |
|
| 7 |
/** |
| 8 |
* @deprecated 2.14.0 |
| 9 |
*/ |
| 10 |
class AddonFieldDataApi extends AddonDataApi |
| 11 |
{ |
| 12 |
/** |
| 13 |
* @var AddonBaseField |
| 14 |
*/ |
| 15 |
protected $_field; |
| 16 |
|
| 17 |
protected $_row; |
| 18 |
|
| 19 |
public function __construct($addon, $field, $object_id, $section_id, $data, $importer_model, $template, $i = 0) |
| 20 |
{ |
| 21 |
parent::__construct($addon, $object_id, $section_id, $data, $importer_model, $template); |
| 22 |
|
| 23 |
$this->_field = $field; |
| 24 |
$this->_row = $i; |
| 25 |
} |
| 26 |
|
| 27 |
public function field() |
| 28 |
{ |
| 29 |
return $this->_field; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_field_id() |
| 33 |
{ |
| 34 |
return $this->_field->get_id(); |
| 35 |
} |
| 36 |
|
| 37 |
public function get_field_data() |
| 38 |
{ |
| 39 |
return $this->data($this->get_field_id()); |
| 40 |
} |
| 41 |
|
| 42 |
public function row() |
| 43 |
{ |
| 44 |
return $this->_row; |
| 45 |
} |
| 46 |
|
| 47 |
public function process_attachment($object_id = null) |
| 48 |
{ |
| 49 |
|
| 50 |
if (is_null($object_id)) { |
| 51 |
$object_id = $this->object_id(); |
| 52 |
} |
| 53 |
|
| 54 |
return $this->field()->process_attachment($object_id); |
| 55 |
} |
| 56 |
|
| 57 |
public function processAttachmentField($value, $post_id, $overrides = []) |
| 58 |
{ |
| 59 |
|
| 60 |
/** |
| 61 |
* @var Filesystem $filesystem |
| 62 |
*/ |
| 63 |
$filesystem = $this->addon()->get_service_provider('filesystem'); |
| 64 |
|
| 65 |
/** |
| 66 |
* @var Ftp $ftp |
| 67 |
*/ |
| 68 |
$ftp = $this->addon()->get_service_provider('ftp'); |
| 69 |
|
| 70 |
/** |
| 71 |
* @var Attachment $attachment |
| 72 |
*/ |
| 73 |
$attachment = $this->addon()->get_service_provider('attachment'); |
| 74 |
|
| 75 |
$raw_records = $this->data(); |
| 76 |
|
| 77 |
$field = $this->field(); |
| 78 |
$field_data = $field->data(); |
| 79 |
|
| 80 |
$prefix = "{$field_data['id']}."; |
| 81 |
|
| 82 |
return $this->template()->process_attachment($post_id, array_merge($raw_records, $overrides), $prefix, $filesystem, $ftp, $attachment); |
| 83 |
} |
| 84 |
} |
| 85 |
|