Raw.php
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace ACA\MetaBox\Export\Model;
use AC;
use ACA\MetaBox\Column;
use ACP;
/**
* @property Column $column
*/
class Raw extends ACP\Export\Model\RawValue {
public function __construct( Column $column ) {
parent::__construct( $column );
}
public function get_value( $id ) {
if ( $this->column->is_clonable() ) {
return $this->get_multiple_values( $id );
}
return $this->format_single_value( rwmb_get_value( $this->column->get_meta_key(), [ 'object_type' => $this->column->get_meta_type() ], $id ), $id );
}
public function format_single_value( $value, $id = null ) {
if ( ! $value ) {
return '';
}
return $value;
}
public function get_multiple_values( $id ) {
$value = rwmb_get_value( $this->column->get_meta_key(), [ 'object_type' => $this->column->get_meta_type() ], $id );
if ( ! $value ) {
return null;
}
$collection = new AC\Collection( (array) $value );
$result = [];
foreach ( $collection as $value ) {
$result[] = $this->format_single_value( $value );
}
return implode( "\r\n", $result );
}
}