Table.php
1.35 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
54
55
56
57
58
59
60
61
62
63
<?php
namespace ACA\BP\Service;
use AC;
use AC\Registerable;
use ACA\BP\Editing\Ajax\TableRows;
use ACA\BP\ListScreen\Email;
use ACA\BP\ListScreen\Group;
class Table implements Registerable {
/**
* @var AC\Asset\Location\Absolute
*/
private $location;
/**
* @param AC\Asset\Location\Absolute $location
*/
public function __construct( AC\Asset\Location\Absolute $location ) {
$this->location = $location;
}
public function register(): void
{
add_action( 'ac/table/list_screen', [ $this, 'init_editable_table' ] );
add_action( 'ac/table_scripts', [ $this, 'table_scripts' ], 1 );
}
private function is_bp_list_screen( $list_screen ) {
return $list_screen instanceof Group ||
$list_screen instanceof Email;
}
/**
* @param AC\ListScreen $list_screen
*/
public function table_scripts( AC\ListScreen $list_screen ) {
if ( ! $this->is_bp_list_screen( $list_screen ) ) {
return;
}
$style = new AC\Asset\Style( 'aca-bp-table', $this->location->with_suffix( 'assets/css/table.css' ) );
$style->enqueue();
}
/**
* @param AC\ListScreen $list_screen
*/
public function init_editable_table( AC\ListScreen $list_screen ) {
if ( ! $list_screen instanceof Group ) {
return;
}
$table_rows = new TableRows\Groups( new AC\Request(), $list_screen );
if ( $table_rows->is_request() ) {
$table_rows->register();
}
}
}