RelationColumnFactory.php
722 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
<?php
namespace ACA\MetaBox;
use ACA\MetaBox;
use ACA\MetaBox\Entity\Relation;
final class RelationColumnFactory {
/**
* @return MetaBox\Column\Relation|null
*/
public function create( Relation $relation ) {
switch ( $relation->get_related_meta_type() ) {
case 'term':
$column = new MetaBox\Column\Relation\Term();
break;
case 'user':
$column = new MetaBox\Column\Relation\User();
break;
case 'post':
$column = new MetaBox\Column\Relation\Post();
break;
default:
return null;
}
$column->set_label( $relation->get_title() );
$column->set_type( $relation->get_type() . '__' . $relation->get_id() );
$column->set_relation( $relation );
return $column;
}
}