Table.php
1.24 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
52
53
<?php
declare(strict_types=1);
namespace ACP\Sorting\Service;
use AC;
use AC\ColumnRepository;
use AC\Registerable;
use ACP\Sorting;
use ACP\Sorting\ModelFactory;
use ACP\Sorting\NativeSortableFactory;
use ACP\Sorting\Settings\ListScreen\PreferredSort;
class Table implements Registerable
{
private $location;
private $native_sortable_factory;
private $model_factory;
public function __construct(
AC\Asset\Location\Absolute $location,
NativeSortableFactory $native_sortable_factory,
ModelFactory $model_factory
) {
$this->location = $location;
$this->native_sortable_factory = $native_sortable_factory;
$this->model_factory = $model_factory;
}
public function register(): void
{
add_action('ac/table/list_screen', [$this, 'init_table'], 11); // After filtering
}
public function init_table(AC\ListScreen $list_screen): void
{
$table = new Sorting\Table\Screen(
$list_screen,
$this->location,
$this->native_sortable_factory->create($list_screen),
$this->model_factory,
new ColumnRepository($list_screen),
new PreferredSort($list_screen)
);
$table->register();
}
}