Aggregate.php
1 month ago
CommentFactory.php
1 month ago
MediaFactory.php
1 month ago
PostFactory.php
1 month ago
UserFactory.php
1 month ago
CommentFactory.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\TableScreenFactory; |
| 6 | |
| 7 | use AC\TableScreen; |
| 8 | use AC\TableScreen\Comment; |
| 9 | use AC\TableScreenFactory; |
| 10 | use AC\Type\TableId; |
| 11 | use WP_Screen; |
| 12 | |
| 13 | class CommentFactory implements TableScreenFactory |
| 14 | { |
| 15 | |
| 16 | public function create(TableId $id): TableScreen |
| 17 | { |
| 18 | return $this->create_table_screen(); |
| 19 | } |
| 20 | |
| 21 | public function create_from_wp_screen(WP_Screen $screen): TableScreen |
| 22 | { |
| 23 | return $this->create_table_screen(); |
| 24 | } |
| 25 | |
| 26 | public function can_create(TableId $id): bool |
| 27 | { |
| 28 | return $id->equals(new TableId('wp-comments')); |
| 29 | } |
| 30 | |
| 31 | public function can_create_from_wp_screen(WP_Screen $screen): bool |
| 32 | { |
| 33 | return 'edit-comments' === $screen->base && 'edit-comments' === $screen->id; |
| 34 | } |
| 35 | |
| 36 | protected function create_table_screen(): Comment |
| 37 | { |
| 38 | return new Comment(); |
| 39 | } |
| 40 | |
| 41 | } |