ListKeysFactory.php
823 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
<?php
declare( strict_types=1 );
namespace AC\Table;
use AC\PostTypeRepository;
use AC\Type\ListKey;
class ListKeysFactory implements ListKeysFactoryInterface {
private $post_type_repository;
public function __construct( PostTypeRepository $post_type_repository ) {
$this->post_type_repository = $post_type_repository;
}
public function create(): ListKeyCollection {
$keys = new ListKeyCollection();
foreach ( $this->post_type_repository->find_all() as $post_type ) {
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object ) {
$keys->add( new ListKey( $post_type ) );
}
}
$keys->add( new ListKey( 'wp-comments' ) );
$keys->add( new ListKey( 'wp-users' ) );
$keys->add( new ListKey( 'wp-media' ) );
do_action( 'ac/list_keys', $keys );
return $keys;
}
}