ValueFormatterFactory.php
772 Bytes
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
<?php
namespace ACA\MetaBox\Value;
use ACA\MetaBox\Column;
class ValueFormatterFactory {
public function create( Column $column, array $field ): Formatter {
switch ( $field['type'] ) {
case 'color':
return new Formatter\Color();
case 'checkbox':
case 'switch':
return new Formatter\Checkbox();
case 'date':
case 'datetime':
if ( $field['timestamp'] ) {
return new Formatter\FormattedDate();
}
return new Formatter\SettingFormatter( $column );
case 'file':
case 'file_advanced':
case 'file_upload':
return new Formatter\File();
case 'select':
case 'select_advanced':
case 'radio':
return new Formatter\Select( $field );
default:
return new Formatter\SettingFormatter( $column );
}
}
}