Comment.php
1 day ago
CommentServiceFactory.php
1 day ago
Media.php
1 day ago
MediaServiceFactory.php
1 day ago
Post.php
1 day ago
PostServiceFactory.php
1 day ago
User.php
1 day ago
UserServiceFactory.php
1 day ago
PostServiceFactory.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\TableScreen\ManageValue; |
| 6 | |
| 7 | use AC\PostType; |
| 8 | use AC\Table\ManageValue\RenderFactory; |
| 9 | use AC\TableScreen; |
| 10 | use AC\TableScreen\ManageValueService; |
| 11 | use AC\TableScreen\ManageValueServiceFactory; |
| 12 | use InvalidArgumentException; |
| 13 | |
| 14 | class PostServiceFactory implements ManageValueServiceFactory |
| 15 | { |
| 16 | public function can_create(TableScreen $table_screen): bool |
| 17 | { |
| 18 | return $table_screen instanceof PostType; |
| 19 | } |
| 20 | |
| 21 | public function create( |
| 22 | TableScreen $table_screen, |
| 23 | RenderFactory $factory, |
| 24 | int $priority = 100 |
| 25 | ): ManageValueService { |
| 26 | if (! $table_screen instanceof PostType) { |
| 27 | throw new InvalidArgumentException('Invalid table screen.'); |
| 28 | } |
| 29 | |
| 30 | return new Post( |
| 31 | $table_screen->get_post_type(), |
| 32 | $factory, |
| 33 | $priority |
| 34 | ); |
| 35 | } |
| 36 | |
| 37 | } |
| 38 |