Endpoints
1 year ago
Validator
2 years ago
Main.php
1 year ago
Messages.php
3 years ago
Post_Repository.php
2 years ago
Service_Provider.php
2 years ago
Main.php
97 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Pods\REST\V1; |
| 4 | |
| 5 | use Pods\REST\Abstracts\Main_Abstract; |
| 6 | |
| 7 | /** |
| 8 | * Class Main |
| 9 | * |
| 10 | * The main entry point for the REST API. |
| 11 | * |
| 12 | * This class should not contain business logic and merely set up and start the REST API support. |
| 13 | * |
| 14 | * @since 2.8.0 |
| 15 | */ |
| 16 | class Main extends Main_Abstract { |
| 17 | |
| 18 | /** |
| 19 | * REST API URL prefix. |
| 20 | * |
| 21 | * This prefix is appended to the REST API URL ones. |
| 22 | * |
| 23 | * @var string |
| 24 | */ |
| 25 | protected $url_prefix = '/pods/v1'; |
| 26 | |
| 27 | /** |
| 28 | * REST API URL prefix. |
| 29 | * |
| 30 | * This prefix is appended to the REST API URL ones. |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | protected $namespace = 'pods'; |
| 35 | |
| 36 | /** |
| 37 | * @var array |
| 38 | */ |
| 39 | protected $registered_endpoints = []; |
| 40 | |
| 41 | /** |
| 42 | * Returns the semantic version for REST API |
| 43 | * |
| 44 | * @since 2.8.0 |
| 45 | * |
| 46 | * @return string |
| 47 | */ |
| 48 | public function get_semantic_version() { |
| 49 | return '1.0.0'; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns the string indicating the REST API version. |
| 54 | * |
| 55 | * @since 2.8.0 |
| 56 | * |
| 57 | * @return string |
| 58 | */ |
| 59 | public function get_version() { |
| 60 | return 'v1'; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns the Pods REST API namespace string that should be used to register a route. |
| 65 | * |
| 66 | * @since 2.8.0 |
| 67 | * |
| 68 | * @return string |
| 69 | */ |
| 70 | public function get_pods_route_namespace() { |
| 71 | return $this->get_namespace() . '/' . $this->get_version(); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the REST API URL prefix that will be appended to the namespace. |
| 76 | * |
| 77 | * The prefix should be in the `/some/path` format. |
| 78 | * |
| 79 | * @since 2.8.0 |
| 80 | * |
| 81 | * @return string |
| 82 | */ |
| 83 | protected function url_prefix() { |
| 84 | return $this->url_prefix; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * {@inheritDoc} |
| 89 | * |
| 90 | * @since 2.8.0 |
| 91 | */ |
| 92 | public function get_reference_url() { |
| 93 | return esc_url( 'https://docs.pods.io/' ); |
| 94 | } |
| 95 | |
| 96 | } |
| 97 |