MetaColumns.php
730 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
<?php
namespace ACA\JetEngine\Service;
use AC;
use AC\ListScreen;
use ACA\JetEngine\ColumnFactory;
use ACA\JetEngine\FieldRepository;
final class MetaColumns implements AC\Registerable {
public function register(): void
{
add_action( 'ac/column_types', [ $this, 'add_meta_columns' ] );
}
public function add_meta_columns( ListScreen $list_screen ) {
$repo = new FieldRepository($list_screen);
$column_factory = new ColumnFactory();
$fields = $repo->find_all();
if ( empty( $fields ) ) {
return;
}
foreach ( $fields as $field ) {
$column = $column_factory->create( $field );
if ( $column ) {
$column->set_field( $field );
$list_screen->register_column_type( $column );
}
}
}
}