Comment.php
5 months ago
CommentServiceFactory.php
5 months ago
Media.php
5 months ago
MediaServiceFactory.php
5 months ago
Post.php
5 months ago
PostServiceFactory.php
5 months ago
User.php
5 months ago
UserServiceFactory.php
5 months 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 | |
| 17 | public function can_create(TableScreen $table_screen): bool |
| 18 | { |
| 19 | return $table_screen instanceof PostType; |
| 20 | } |
| 21 | |
| 22 | public function create( |
| 23 | TableScreen $table_screen, |
| 24 | RenderFactory $factory, |
| 25 | int $priority = 100 |
| 26 | ): ManageValueService { |
| 27 | if ( ! $table_screen instanceof PostType) { |
| 28 | throw new InvalidArgumentException('Invalid table screen.'); |
| 29 | } |
| 30 | |
| 31 | return new Post( |
| 32 | $table_screen->get_post_type(), |
| 33 | $factory, |
| 34 | $priority |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | } |