QueryFactory.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Acf\FieldGroup; |
| 6 | |
| 7 | use AC\PostType; |
| 8 | use AC\TableScreen; |
| 9 | |
| 10 | class QueryFactory |
| 11 | { |
| 12 | public function create(TableScreen $table_screen): ?Query |
| 13 | { |
| 14 | if ($table_screen instanceof TableScreen\Media) { |
| 15 | return new Location\Media(); |
| 16 | } |
| 17 | |
| 18 | if ($table_screen instanceof TableScreen\Comment) { |
| 19 | return new Location\Comment(); |
| 20 | } |
| 21 | |
| 22 | if ($table_screen instanceof PostType) { |
| 23 | return new Location\Post((string)$table_screen->get_post_type()); |
| 24 | } |
| 25 | |
| 26 | if ($table_screen instanceof TableScreen\User) { |
| 27 | return new Location\User(); |
| 28 | } |
| 29 | |
| 30 | return null; |
| 31 | } |
| 32 | |
| 33 | } |
| 34 |